View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dan Thompson Dan Thompson is offline
external usenet poster
 
Posts: 125
Default NEED HELP with Range command

Yes thank you bro, I apreciate the concept of using the A:F,H:J ect.....
however the rest of the code is based on dynamic information so I have know
way of knowing if it is going to be A:H or C:H or A:D you get the Idea.
The only way I can posibly think of that would work is to write some kind of
code that would be smart enought to look at a line like this

MyString =
"A:A,B:B,C:C,D:D,E:E,F:F,G:G,H:H,K:K,N:N,Q:Q,R:R,S :S,T:T,X:X,AA:AA" ect....

and be able to have some code convert the above line into somthing like the
following

MyString = "A:H,K:K,N:N,Q:T,X:X,AA:AA"

But I didn't realy want to have to write code to do that because it seams
like alot of extra work when VBA should just be able to handle really long
strings like the first one assigned to a Range

example: MyRange = Range(MyString).Select

keep in mind this will work with the example I had above because it is short
enough, I just didn't want to type in the actual string from my code because
it is like 220 characters long or more.


"broro183" wrote:


Hi Dan,
Tom's given you the best answer already (split into 2 lots & start from
the right) but just to expand on it...

Your initial post stated:
Range("A:A,B:B,C:C,F:F,AB:AB,AC:AC,BF:BF").Select

This can be shortened to include any consecutive columns in the same
range ie
Range("A:C,F:F,AB:AC,BF:BF").Select
(This would happen if you left click on the first column eg A & then
held it down while dragging the mouse over the columns next to it eg B
& C.)

If you are just deleting them (I think?) it can be safely changed to
Range("A:C,F:F,AB:AC,BF:BF").delete

hth
Rob Brockett
NZ
always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=560324