Thread: column loop
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1374_] Rick Rothstein \(MVP - VB\)[_1374_] is offline
external usenet poster
 
Posts: 1
Default column loop

These statements replace the 6 If-Then statements you posted....

If iKN 0 And iKN < 7 Then
Set CellRangePMR = Worksheets("PM").Range(Chr(66 + iKN) & _
"6:" & Chr(66 + iKNX) & CStr(PMR + 5))
End If

If the only values for iKN are 1 through 6 (for example, if they are being
generated by a loop counter), then you don't need the If-Then or End If
statements.

Rick


"Gijs Breedveld" wrote in message
...
How can I change the column charater in a loop for the following:

If iKN = 1 Then Set CellRangePMR = Worksheets("PM").Range("C6:c" & PMR +
5)
If iKN = 2 Then Set CellRangePMR = Worksheets("PM").Range("d6:d" & PMR +
5)
If iKN = 3 Then Set CellRangePMR = Worksheets("PM").Range("e6:e" & PMR +
5)
If iKN = 4 Then Set CellRangePMR = Worksheets("PM").Range("f6:f" & PMR +
5)
If iKN = 5 Then Set CellRangePMR = Worksheets("PM").Range("g6:g" & PMR +
5)
If iKN = 6 Then Set CellRangePMR = Worksheets("PM").Range("h6:h" & PMR +
5)

Best regards,

Gijs