|
-
Sep 27th, 2005, 10:56 AM
#1
Range Return (ECXCEL)
ok.. here is another question:
I have code that scans sheets for protected cells (Thanks DKenny )
it fills out a new sheet with each cell range like this
Sheet1!A16
Sheet1!A17
etc...
what I would like to do is translate this into a range.. so I dont have 100 or 1000 individual cells listed..
I tried this:
Range("A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13").Select
then
Msgbox Selection.Address
but it returns the same as above $A$2,$A$3 etc..
I would like to get it to return A2:A13
thanks!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Sep 27th, 2005, 12:00 PM
#2
Re: Range Return (ECXCEL)
Hi,
You could use the Row and Column properties of the returned Cell object to figure out if they are in sequence, then construct a range from that.
I'm thinking something along the lines of putting the checker in a loop which identifies the row and column of the next Cell in the list - if neighbouring then stay in the loop and check for the next item, if not then end the current "range" and start another.
Does that make sense?
zaza
-
Sep 27th, 2005, 12:01 PM
#3
Re: Range Return (ECXCEL)
I had thought of that.. but wanted to see if there is an Easier solution 
Thanks!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Sep 27th, 2005, 01:37 PM
#4
Re: Range Return (ECXCEL)
ok, I got it 
by setting the print area it figures the ranges correctly..
then I can just split it up how I want...
and reset the print area
VB Code:
'other code...
WS.Activate
WS.Range(tmpRange).Select
tmpPA = WS.PageSetup.PrintArea
WS.PageSetup.PrintArea = Selection.Address
tmpRange = ActiveSheet.PageSetup.PrintArea
WS.PageSetup.PrintArea = tmpPA
'other code...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
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
|