• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

moving left column

pradeep kalele

New Member
I want to change the color of ActiveCell and after that it should move to 2 column left and change the color of that cell
I have put the following code but when ActiveCell (1, -2) command is given it says "Sytax Error.
Kindly help
Thanks & regards

Sub SetColor()

ActiveCell.Interior.ColorIndex = 1
ActiveCell.Interior.ColorIndex = 2
ActiveCell.Interior.ColorIndex = 3
ActiveCell.Interior.ColorIndex = 4
ActiveCell.Interior.ColorIndex = 0
ActiveCell.Interior.ColorIndex = 5
ActiveCell.Interior.ColorIndex = 6
ActiveCell.Interior.ColorIndex = 7
ActiveCell.Interior.ColorIndex = 8
ActiveCell.Interior.ColorIndex = 9
ActiveCell.Interior.ColorIndex = 10
ActiveCell.Interior.ColorIndex = 11
ActiveCell.Interior.ColorIndex = 12
ActiveCell.Interior.ColorIndex = 13
ActiveCell.Interior.ColorIndex = 14
ActiveCell.Interior.ColorIndex = 15
ActiveCell.Interior.ColorIndex = 16
ActiveCell.Interior.ColorIndex = 17
ActiveCell(1, -2)
ActiveCell.Interio.ColorIndex = 3
 
Maybe something like this:

Code:
Option Explicit

Sub ASetColor()
    Dim i As Long, j As Long
    ActiveCell.Interior.ColorIndex = 1
    j = 2
    For i = 2 To 17 Step 2
        ActiveCell.Offset(0, -i).Interior.ColorIndex = j
        j = j + 1
    Next i
End Sub
 
Back
Top