• 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.

I have this macro i need some changes

Abhijeet

Active Member
Hi
I have this macro i want when excel refresh then change the numbers and i want change the cell font color then next time down cell font color i want its going down then
 

Attachments

  • Random.xlsm
    14.8 KB · Views: 3
I think you are saying that you want to toggle back and forth between two colors. In which case, change Module1's code to this:
Code:
Dim myToggle As Boolean
Public Sub EventMacro()
Dim myColor As Long
    Sheet1.Calculate
    myToggle = Not (myToggle)
    If myToggle Then
        myColor = 3
    Else
        myColor = 4
    End If
    Cells.SpecialCells(xlCellTypeFormulas).Interior.ColorIndex = myColor
    alertTime = Now + TimeValue("00:00:05")
    Application.OnTime alertTime, "EventMacro"
End Sub
 
Note to other readers: Workbook will call a self-calling macro, with no end limit. To stop the loop, will need to either edit the macro and remove the recursive call, or shut XL completely.
 
Hi Luke i want one by one cell change the color when 1st cell color red then next time 2 cell color change to red and 1st cell normal going down till the data
 
In that case...
Code:
Dim myRow As Long
Public Sub EventMacro()
Dim lastRow As Long
'Clear old format
'In case of initial call, when myRow = 0
On Error Resume Next
Cells(myRow, "A").Interior.ColorIndex = xlNone
On Error GoTo 0

lastRow = Cells(Rows.Count, "A").End(xlUp).Row

Sheet1.Calculate
myRow = myRow + 1

'Setup boundary conditions
If myRow < 2 Or myRow > lastRow Then myRow = 2

Cells(myRow, 1).Interior.ColorIndex = 3 'Change this to color desired
alertTime = Now + TimeValue("00:00:05")
Application.OnTime alertTime, "EventMacro"
End Sub
 
Back
Top