+ Reply to Thread
Results 1 to 3 of 3

Don't understand vb resize code..help needed

  1. #1
    Registered User
    Join Date
    09-15-2011
    Location
    Mississippi
    MS-Off Ver
    Excel 2007
    Posts
    13

    Smile Don't understand vb resize code..help needed

    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

  2. #2
    Registered User
    Join Date
    09-15-2011
    Location
    Mississippi
    MS-Off Ver
    Excel 2007
    Posts
    13

    Smile Re: Dnt Understanding VB Resize code

    Can anyone help in explaining what this line of code means????

    With ar.Resize(ar.Rows.Count + 1).Offset(-1, Col)[/QUOTE]

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Don't understand vb resize code..help needed

    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 Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1