PDA

View Full Version : Solved: Dynamic Ranges



jmenche
05-26-2011, 09:15 AM
Folks,

I want to write a routine that loops through rows. Every time through the loop, I want to select range C through G with whatever row i'm on. I've done this with only one with success ("C5:G" & lastcolumn, e.g.). I cannot find the magic syntax for two.

Here is what I am trying to do. If i is my row counter, how can I select range("C" & i & ":G" & i)?? I cannot figger out how to throw the colon in there.

Thanks
:beerchug:

CharlesH
05-26-2011, 11:41 AM
Hi,

See if this helps.



Sub ww()
Dim i As Integer
For i = 1 To 3
Range("C" & i & ":G" & i).Select
Next
End Sub

jmenche
05-26-2011, 11:44 AM
I just realized that I had written that too. However, I couldn't get it right when I was in the VBE.

Cheers

Rayman
05-26-2011, 12:41 PM
Try This


Range("C" & i, "G" & i)