PDA

View Full Version : Solved: For Each Loop- Multiple columns?



YellowLabPro
04-07-2007, 06:49 PM
In this line of code, it targets column "D" or 4, can I specifiy another non-adjacent column in the same line w/out having to repeat the entire code for another column?
For Each c In Intersect(Ws.Columns(4), Ws.UsedRange)

ie.
For Each c In Intersect(Ws.Columns(4) & (23), Ws.UsedRange)

johnske
04-07-2007, 08:39 PM
IMO using the range object in conjunction with the column letter(s) is easier and should get you what you want, e.g.For Each c In Application.Intersect(Ws.Range("D:D, W:W"), Ws.UsedRange)

YellowLabPro
04-08-2007, 06:10 AM
Thanks Johnske