Results 1 to 4 of 4

Thread: [SOLVED] Pass first cell address in range object to other range object

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    [SOLVED] Pass first cell address in range object to other range object

    I have a macro that allows the user to select a range and the selection is passed to a Range variable. However I need another variable that is automatically assigned the FIRST (upper-left) address of the user selected range. The first part is easy but I'm having trouble with the second (assign first cell) part:

    Code:
    Sub assign_range
    Dim rngWholeRange as Range
    Dim rngFirstCell as Range
    
    Set rngWholeRange = Selection
    Set rngFirstCell = rngWholeRange.Address(0,0)
    
    End Sub
    I've tried all sorts of variations of the above but can't get it to asssign cell (0,0) from rngWholeRange to the address of rngFirstCell. Any suggestions?

    Regards
    -Rob
    Last edited by TheRobster; Jun 17th, 2015 at 06:07 AM.
    http://www.sudsolutions.com

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Excel: pass first cell address in range object to other range object

    From my phone, but something like:

    Cells(rngWholeRange.Row, rngWholeRange.Column).Address

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel: pass first cell address in range object to other range object

    you could try like
    Code:
    Set r = Range("g6:p11")
    Set c = r(1)
    MsgBox c.Address
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Re: Excel: pass first cell address in range object to other range object

    Cheers guys :-)
    http://www.sudsolutions.com

Posting Permissions

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



Click Here to Expand Forum to Full Width