ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loop syntax (https://www.excelbanter.com/excel-programming/361734-loop-syntax.html)

Knox

loop syntax
 
can someone correct the syntax in the last line below. Thank you

I just want C(24*i+2):C(24*i+25) to be selected. thanx

Dim i As Long
For i = 1 To 1
Range("C" & 24 * i + 2:"C" & 24 * i + 25).Select

Dave Peterson

loop syntax
 
Maybe:

Range("C" & 24 * i + 2 & ":C" & 24 * i + 25).Select
Or
Cells(24 * i + 2, "C").Resize(24, 1).Select
or
Range("C" & 24 * i + 2).Resize(24, 1).Select

I like the middle one!


Knox wrote:

can someone correct the syntax in the last line below. Thank you

I just want C(24*i+2):C(24*i+25) to be selected. thanx

Dim i As Long
For i = 1 To 1
Range("C" & 24 * i + 2:"C" & 24 * i + 25).Select


--

Dave Peterson

Knox

loop syntax
 
nevermind i got it

Range(("C" & 24 * i + 2), ("C" & 24 * i + 25)).Select

thanx

"Knox" wrote:

can someone correct the syntax in the last line below. Thank you

I just want C(24*i+2):C(24*i+25) to be selected. thanx

Dim i As Long
For i = 1 To 1
Range("C" & 24 * i + 2:"C" & 24 * i + 25).Select



All times are GMT +1. The time now is 12:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com