![]() The argument Cell1 requires the name of the range. If in the above you leave out the worksheet or workbook the Application.Range method will assume the active one: Application.Range("Sheet2!A3:B5") - in the active workbookĪpplication.Range("A3:B5") - in the active worksheet 'The Set keyword is required to assign an object to a variable (such as range)'ĭebug.Print "" & & "!" & rng.Address Set rng = Application.Range(Cell1:="Sheet2!A3:B5") Dim rng As Range 'Declares a variable rng of type Range' ![]() It shows you can specify any range in an open workbook on any worksheet. The code below returns Sheet2!$A$3:$B$5 in the Immediate window. Using the Range methods Application.Range - general use This only happens with the Select and Activate methods - whose use is generally considered harmful / should be avoided. Normally, setting a range does not change the active range. Ranges being the core of Excel, VBA provides many such procedures. Setting a range variable is done by using a procedure that returns a range. Download Code VBA Set range variable using VBA in Excel
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |