lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
The code below is to print colorindex code (from 1-56). It works fine but I want to print these codes into 4 columns (each has 14 cells). I know I need to break the For-Next look when x=14
but I do not know how and I would like to learn from your style how that can be done. I am thinking to inset If statement to check if x=14 and to exit the loop accordingly. Thank you so much.
The code below is to print colorindex code (from 1-56). It works fine but I want to print these codes into 4 columns (each has 14 cells). I know I need to break the For-Next look when x=14
but I do not know how and I would like to learn from your style how that can be done. I am thinking to inset If statement to check if x=14 and to exit the loop accordingly. Thank you so much.
Code:
Sub colorindexall()
Dim x As Integer
For x = 1 To 56
Cells(x, 1).Interior.ColorIndex = x
Cells(x, 1).Value = x
Next
End Sub