ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For i = 5 to 1000 for columns? (https://www.excelbanter.com/excel-programming/368809-i-%3D-5-1000-columns.html)

[email protected]

For i = 5 to 1000 for columns?
 
Hello there
I am quite often using functions such as
____________
For i = x to whatever
CODE
Next i
___________

but I would also like to use this kind of structure for columns such as

For ? = A to J
CODE
Next ?

But obviously its not this kind of structure anymore, do you know what
to use?

kind regards,
Daniel


NickHK

For i = 5 to 1000 for columns?
 
Here's one way:
Dim Col As Range
For Each Col In Range("A:F").Columns
Col.ColumnWidth = 12
Next

NickHK
P.S. You know Excel version before the 207 Beta only have 256 columns, so
you can't go as high as 1000.

wrote in message
ups.com...
Hello there
I am quite often using functions such as
____________
For i = x to whatever
CODE
Next i
___________

but I would also like to use this kind of structure for columns such as

For ? = A to J
CODE
Next ?

But obviously its not this kind of structure anymore, do you know what
to use?

kind regards,
Daniel




Norman Jones

For i = 5 to 1000 for columns?
 
Hi Daniel,

Try something like:

'=============
Public Sub Tester()
Dim i As Long

For i = 1 To 20 Step 2
Columns(i).Interior.ColorIndex = 6
Next i

End Sub
'<<=============


---
Regards,
Norman



wrote in message
ups.com...
Hello there
I am quite often using functions such as
____________
For i = x to whatever
CODE
Next i
___________

but I would also like to use this kind of structure for columns such as

For ? = A to J
CODE
Next ?

But obviously its not this kind of structure anymore, do you know what
to use?

kind regards,
Daniel




[email protected]

For i = 5 to 1000 for columns?
 
Thats just great Nick, Norman!
many thanks for your help I am just testing all this but I am sure it
will be just fine.
Once again, thanks for your help
Daniel

Norman Jones wrote:
Hi Daniel,

Try something like:

'=============
Public Sub Tester()
Dim i As Long

For i = 1 To 20 Step 2
Columns(i).Interior.ColorIndex = 6
Next i

End Sub
'<<=============


---
Regards,
Norman



wrote in message
ups.com...
Hello there
I am quite often using functions such as
____________
For i = x to whatever
CODE
Next i
___________

but I would also like to use this kind of structure for columns such as

For ? = A to J
CODE
Next ?

But obviously its not this kind of structure anymore, do you know what
to use?

kind regards,
Daniel



[email protected]

For i = 5 to 1000 for columns?
 
Working just fine indeed
Many thanks
Daniel

wrote:
Thats just great Nick, Norman!
many thanks for your help I am just testing all this but I am sure it
will be just fine.
Once again, thanks for your help
Daniel

Norman Jones wrote:
Hi Daniel,

Try something like:

'=============
Public Sub Tester()
Dim i As Long

For i = 1 To 20 Step 2
Columns(i).Interior.ColorIndex = 6
Next i

End Sub
'<<=============


---
Regards,
Norman



wrote in message
ups.com...
Hello there
I am quite often using functions such as
____________
For i = x to whatever
CODE
Next i
___________

but I would also like to use this kind of structure for columns such as

For ? = A to J
CODE
Next ?

But obviously its not this kind of structure anymore, do you know what
to use?

kind regards,
Daniel




All times are GMT +1. The time now is 10:50 AM.

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