Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Running macro
I would like to have this macro running not only when he workbook is opened
but also if it already is open: Private Sub Workbook_Open() Dim xR As Long With Sheets("Databas") For xR = 3 To .Cells(.Rows.Count, "F").End(xlUp).Row If .Cells(xR, "F") 4500 Then .Rows(xR).EntireRow.Interior.Color = vbYellow End If If .Cells(xR, "K") 1 Then .Rows(xR).EntireRow.Interior.Color = vbRed End If If .Cells(xR, "M") 1 Then .Rows(xR).EntireRow.Interior.Color = 15773696 End If Next End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Running macro
Stick this Sub in a general module.
Sub run_a_macro() Dim xR As Long With Sheets("Databas") For xR = 3 To .Cells(.Rows.Count, "F").End(xlUp).Row If .Cells(xR, "F") 4500 Then .Rows(xR).EntireRow.Interior.Color = vbYellow End If If .Cells(xR, "K") 1 Then .Rows(xR).EntireRow.Interior.Color = vbRed End If If .Cells(xR, "M") 1 Then .Rows(xR).EntireRow.Interior.Color = 15773696 End If Next End With End Sub Stick this in Thisworkbook module Private Sub Workbook_Open() run_a_macro End Sub Gord Dibben MS Excel MVP On Sat, 5 Apr 2008 09:15:02 -0700, Kjellk wrote: I would like to have this macro running not only when he workbook is opened but also if it already is open: Private Sub Workbook_Open() Dim xR As Long With Sheets("Databas") For xR = 3 To .Cells(.Rows.Count, "F").End(xlUp).Row If .Cells(xR, "F") 4500 Then .Rows(xR).EntireRow.Interior.Color = vbYellow End If If .Cells(xR, "K") 1 Then .Rows(xR).EntireRow.Interior.Color = vbRed End If If .Cells(xR, "M") 1 Then .Rows(xR).EntireRow.Interior.Color = 15773696 End If Next End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Report with macro losing links to a particular worksheet after running macro | Excel Programming | |||
disable user running macro from Tools Macro | Excel Discussion (Misc queries) | |||
Need syntax for RUNning a Word macro with an argument, called from an Excel macro | Excel Programming | |||
running a macro ina workbook that doesnt have that macro | Excel Programming | |||
Launch Macro in Access via Macro running in Excel??? | Excel Programming |