Can anyone help in explaining what this line of code means????
With ar.Resize(ar.Rows.Count + 1).Offset(-1, Col)
Can anyone help in explaining what this line of code means????
With ar.Resize(ar.Rows.Count + 1).Offset(-1, Col)
Last edited by Darel; 09-30-2011 at 01:27 PM. Reason: Title not appropriate
Can anyone help in explaining what this line of code means????
With ar.Resize(ar.Rows.Count + 1).Offset(-1, Col)[/QUOTE]
Hello Darel,
The code is changing the cell to be reference. This is easier to explain using an actual address.
Variable ar is C2:C9
Variable Col is 2
ar.Rows.Count + 1 = 8 + 1 = 9
Using substitution, ar.Resize(9) expands the range reference to C2:C10. One row past the last row in ar. The Resize method has 2 named arguments: RowSize, ColumnSize. Resize(9) so it can be written 2 other ways.
Resize(9,) or Resize(RowSize:=9)The comma indicates another argument is to follow. If left empty then the row or column remains the same. Personally, I prefer to used the named arguments if only is given. It is easy to miss the comma.
The Offset method creates a reference relative to the range C2:C10. The -1 indicates that row is 1 row up from C2 or C1. The variable Col is 2 which moves the column to the right 2 columns or column "E".
The final reference is then to the range E1:E9.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks