Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Report with macro losing links to a particular worksheet after running macro santhu Excel Programming 0 March 1st 07 03:25 AM
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
running a macro ina workbook that doesnt have that macro Paul Excel Programming 2 February 18th 04 01:47 AM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


All times are GMT +1. The time now is 06:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"