Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiple Discrete Columns Selection

Hi all,

Sorry for this stupid question.
If I want to select Columns H, Q, R, S at the same time, how can
achieve this by VBA code?

Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Multiple Discrete Columns Selection


Range("H:H,Q:S").Select
--
XL2002
Regards

William



"kaon " wrote in message
...
| Hi all,
|
| Sorry for this stupid question.
| If I want to select Columns H, Q, R, S at the same time, how can I
| achieve this by VBA code?
|
| Thanks.
|
|
| ---
| Message posted from
http://www.ExcelForum.com/
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiple Discrete Columns Selection

Thx for quick reply.

One more question.
Suppose I declare the range Y to be the above one mentioned. How can
intersect the used range with the range Y so that other columns i
selected?

To illustrate:
A B C <-- Column C is selected to be range Y
Now I want to select columns A and B, not C to be selected.

Thanks

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Multiple Discrete Columns Selection

Dim y as Range, rng as Range, col as Range
set y = Range("H:H,Q:S")
for each col in Activesheet.UsedRange.Columns
if intersect(col,y) is nothing then
if rng is nothing then
set rng = col
else
set rng = union(rng,col)
end if
End if
Next
' if you want the entire column
if not rng is nothing then
set rng = rng.entireColumn
msgbox rng.Address
End if

--
Regards,
Tom Ogilvy


"kaon " wrote in message
...
Thx for quick reply.

One more question.
Suppose I declare the range Y to be the above one mentioned. How can I
intersect the used range with the range Y so that other columns is
selected?

To illustrate:
A B C <-- Column C is selected to be range Y
Now I want to select columns A and B, not C to be selected.

Thanks.


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiple Discrete Columns Selection

Oh thanks.
Seems I should spend more time on developing the right code. :

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Selection when Grouping columns adrian Excel Discussion (Misc queries) 0 March 19th 10 11:10 AM
2 stacked, one discrete Ken W Charts and Charting in Excel 1 June 4th 09 12:41 PM
Break a table into discrete info RJB Excel Discussion (Misc queries) 2 June 14th 08 04:18 AM
Selecting Multiple Columns in a Named Selection Griffithpt Excel Worksheet Functions 0 August 9th 06 10:54 PM
Drop-down selection fills data across multiple columns Tom Excel Discussion (Misc queries) 7 December 2nd 04 12:43 AM


All times are GMT +1. The time now is 10:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"