-
Jun 17th, 2015, 03:27 AM
#1
Thread Starter
Hyperactive Member
[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
-
Jun 17th, 2015, 04:19 AM
#2
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
-
Jun 17th, 2015, 05:04 AM
#3
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
-
Jun 17th, 2015, 06:09 AM
#4
Thread Starter
Hyperactive Member
Re: Excel: pass first cell address in range object to other range object
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|