Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to run on openinng worksheet

Does anyone know how to make a macro run automatically
when you open a worksheet, and not have to rely on
hitting a button or a shortcut key?

I want the sheet to flash a couple of times, so this is
the code:

' Keyboard Shortcut: Ctrl+y
'
Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select
Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select

Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select

Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select

End Sub


Cheers
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Macro to run on openinng worksheet

Hi

Do you want to flash the sheet, whenever you activate it, or when you open
the workbook.

When the 1st is the case, use worksheets Activate event (Alt+F11,
right-click on worksheet in VBA-Project window, select 'View code', in Code
window select Worksheet from dropdown list and Activate from another one).

When the 2nd is the case, use workbooks Open event (in VBA-Project window
right-click on ThisWorkbook, etc.)


--
Arvi Laanemets
(When sending e-mail, use address arvil<Attarkon.ee)


"Ian_Cee" wrote in message
...
Does anyone know how to make a macro run automatically
when you open a worksheet, and not have to rely on
hitting a button or a shortcut key?

I want the sheet to flash a couple of times, so this is
the code:

' Keyboard Shortcut: Ctrl+y
'
Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select
Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select

Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select

Cells.Select
With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
End With
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A1").Select

End Sub


Cheers



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to run on openinng worksheet

just put your code in a sub called Auto_open

for example

Sub Auto_Open()
' your code here
End Sub

- Manges

--
Message posted from http://www.ExcelForum.com

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
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


All times are GMT +1. The time now is 04:49 AM.

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"