+ Reply to Thread
Results 1 to 5 of 5

Returning A Range

Hybrid View

twills Returning A Range 07-19-2010, 07:47 AM
snb Re: Very Simple - Returning A... 07-19-2010, 07:53 AM
sweep Re: Very Simple - Returning A... 07-19-2010, 07:56 AM
romperstomper Re: Very Simple - Returning A... 07-19-2010, 07:55 AM
twills Re: Returning A Range 07-19-2010, 10:18 AM
  1. #1
    Registered User
    Join Date
    04-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Returning A Range

    Hi,

    I have a very simple query that I'm sure someone will be able to solve in seconds.

    I have a spreadsheet and I'd like to get a specific range returned for use in a later function.

    The range itself starts in cell A3 and extends downwards until the cell just above an empty cell in the same column (A). The trick of course is that the number of cells with data in them may change and hence the position of the empty cell in column A may also change.

    I've attached a spreadsheet with a simple depiction of what I mean.

    Should you have any further questions or queries, please don't hesistate to ask.

    Many thanks in advance for your help,

    Kindest Regards,
    Twills.
    Attached Files Attached Files
    Last edited by twills; 07-19-2010 at 10:17 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Very Simple - Returning A Range

    Explore 'currentregion' in the VBEditor helpfiles.

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Very Simple - Returning A Range

    Something like this?

    Set RangeNeeded = Range(Range("A3"), Range("A3").End(xlDown))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,974

    Re: Very Simple - Returning A Range

    For example:
        Dim rng As Range
        If Len(Range("A4").Formula) = 0 Then
            Set rng = Range("A3")
        Else
            Set rng = Range("A3", Range("A3").End(xlDown))
        End If
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Registered User
    Join Date
    04-18-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Returning A Range

    Guys,

    Thanks for the help, much appreciated.

    Kindest Regards,
    Twills

+ 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.6.0 RC 1