lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I wrote the code below to change the color of each cell in a selection. Do you think it is good and efficient code? How you would do it yourself. Thank you so much.
update: I just found that if the selection is big then the code will fail because colorindex will be more than 56. Hence, I will see how you would do it. Thank you
I wrote the code below to change the color of each cell in a selection. Do you think it is good and efficient code? How you would do it yourself. Thank you so much.
Code:
Sub myselection()
Dim xcell As Range
Dim i As Integer
i = 1
For Each xcell In Selection
xcell.Interior.ColorIndex = i
i = i + 1
Next
End Sub
update: I just found that if the selection is big then the code will fail because colorindex will be more than 56. Hence, I will see how you would do it. Thank you
Last edited: