+ Reply to Thread
Results 1 to 3 of 3

Range selection code

  1. #1
    Registered User
    Join Date
    11-17-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Range selection code

    Hey guys, I need some help with the wording for a line of code ...

    Info is imported from one spreadsheet to this one. There will always be info in Columns A:D, but the number of rows always varies. Data is contiguous throughout Column A, but that is not true for all other columns. I want to write a code that always selects the next to last cell with data in Column A, to cell D2. In other words, for this particular scenario, I would want the range selected to be A6:D2. If data in Column A were to go to cell A200, I would want the range selected to be A99:D2 ... if data went to cell A1000, I would want the range selected to be A999:D2, etc. I know this will probably be a very simple answer, but what would the Range code look like for this? Thanks!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,613

    Re: Range selection code

    Try this...

    Range("A2:D" & Range("A" & Rows.Count).End(xlUp).Row - 1).Select

  3. #3
    Registered User
    Join Date
    11-17-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Range selection code

    Awesome, this works perfectly! You're a lifesaver, thanks!

+ 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