Thread: Parallel ranges
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Parallel ranges

This

Set Rng2 = Rng1.Offset(, Col - 1)

worked fine for me:

Sub TryNow()
Dim Rng1 As Range
Dim Rng2 As Range
Dim Col As Integer

Col = 3

Set Rng1 = Range("A1:A3,B10:B12")
MsgBox Rng1.Address
Set Rng2 = Rng1.Offset(, Col - 1)
MsgBox Rng2.Address

End Sub


--
HTH,
Bernie
MS Excel MVP


"Dave Unger" wrote in message
oups.com...
Hello,

I have a situation where the user makes a selection in column
"A" (rng1). I need to create parallel ranges of this selection in
other columns on the same sheet (rng2). The following line of code
works well for single area selections, but only sets the first area on
multiple area selections.

Set rng2 = Range(rng1.Address).Offset(, col - 1)

I can accomplish what I want by looping through each area in column A,
but this seems to be somewhat inefficient when there's a lot of
columns involved. There must be a better way (hopefully). Thank you
for your suggestions.

I'm using Excel 97

Regards,

Dave