Why does this code work? I always get confused as to how vba reads range/cell inputs. Like, does it return a number or a string and can range/cell read a number or a string. Any insight?
Please Login or Register to view this content.
Why does this code work? I always get confused as to how vba reads range/cell inputs. Like, does it return a number or a string and can range/cell read a number or a string. Any insight?
Please Login or Register to view this content.
Last edited by ammartino44; 09-28-2015 at 12:42 PM.
The range object of a worksheet takes different values and creates a range object from those inputs.
The most commonly used is just an address string:
Another way is to use two range objects, used to determine the "corners" of a rangePlease Login or Register to view this content.
though the corners used don't really matter - this is the same range as the example immediately above - what matters is the first and last rows and the left-most and right-most columns to define the block of cellsPlease Login or Register to view this content.
Your example is just a variation on this technique: Activecell is a range, and Cells(r,c) is another rangePlease Login or Register to view this content.
And you can mix strings and range objects as the anchors, so this works as well:Please Login or Register to view this content.
Please Login or Register to view this content.
Bernie Deitrick
Excel MVP 2000-2010
It selects a Range. In this instance your variables r and c need too be defined. r would represent a number value for the row, and c would represent a number value for the column. Therefore from the activecell it will offset to values defined to select a range. For example in this scenario.
It would select row 6 column 3 or cells(6,3) and select the whole range between that cell and the activecell.Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks