|
-
Aug 4th, 2012, 01:48 AM
#1
Thread Starter
Member
split range address into individual cell addresses
hi,
Given a range say, "A1:E1", i need a formula OR a single line of code to return a string of cells "A1","B1","C1","D1","E1". I do not want to use helper columns if it is a worksheetfunction, OR loops if its a VBA code.
has anyone tried something like this?
Function SplitRange(myRng as Range) as String
.....
.....
SplitRange= .....
End Function
-
Aug 4th, 2012, 04:18 AM
#2
Re: split range address into individual cell addresses
very easy in vba, but not without loop
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
-
Aug 4th, 2012, 08:38 AM
#3
Thread Starter
Member
Re: split range address into individual cell addresses
well, i know how to do it using a loop, but i need a one-liner code without a loop OR an some worksheet array formula that returns an array of strings, which i can then use it as a single line of code into my VBA code.
-
Aug 4th, 2012, 10:27 AM
#4
Thread Starter
Member
Re: split range address into individual cell addresses
i worked out this worksheet Array formula:
={SUBSTITUTE(CELL("address",INDEX(A1:E1,1,COLUMN(A1:E1))),"$","")}
which gives me correct result i.e. "A1","B1","C1","D1","E1" across multiple cells.
But question is: how do you i convert this into a single-line code in VBA? as far as i know, the worksheet CELL function does not have any equivalent in VBA.
Tags for this Thread
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
|