+ Reply to Thread
Results 1 to 3 of 3

Thread: Selecting range up to blank row

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    Bridgwater, UK
    MS-Off Ver
    Excel 2003
    Posts
    17

    Selecting range up to blank row

    I am having a few problems selecting a range. What I am trying to do is select a range where the number of columns stay the same, but the rows are variable; ranging from one row upwards. At the end of the rows, there is a blank row. I currently have;

    Sub CopyRange()
      Range("A7", "L7").Select
      Range(Selection, Selection.End(xlDown)).Select
      Selection.Copy
    End Sub
    However, the selection of the range down goes past the blank row and I cannot find out how to select just down to the blank row.

    I am not worried as to whether the blank row is included in the selection or not, just that it selects the rows that are required.

    TIA
    Last edited by FoxIII; 02-09-2009 at 05:27 AM.

  2. #2
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,247

    Re: Selecting range up to blank row

    Dim LastRow As Long
    
        LastRow = Cells.Find(What:="*", _
                            After:=Range("A7"), _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext).Row
        Range("A7:L7").Resize(LastRow - 6).Select
        Selection.Copy

  3. #3
    Registered User
    Join Date
    02-08-2009
    Location
    Bridgwater, UK
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Selecting range up to blank row

    Thank you Bob! That works perfectly

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0