Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Running a Marcro when sheet is opened

I recorde a simple macro to hide all the blank cells in a sheet and pasted
into the code of a command button as follws:

Private Sub CommandButton1_Click()
Range("B6:K425").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<"
End Sub

What I would like to do is have this macro apply when the sheet is opened
but I don't know what to enter after the 'Private Sub' bit instead of
CommandButton1_Click().

Can anyone help please.

Thanks a plenty in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Running a Marcro when sheet is opened

Try This :

Private Sub Worksheet_Activate()

Jason Zischke

"Mark Dullingham" wrote:

I recorde a simple macro to hide all the blank cells in a sheet and pasted
into the code of a command button as follws:

Private Sub CommandButton1_Click()
Range("B6:K425").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<"
End Sub

What I would like to do is have this macro apply when the sheet is opened
but I don't know what to enter after the 'Private Sub' bit instead of
CommandButton1_Click().

Can anyone help please.

Thanks a plenty in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Running a Marcro when sheet is opened

Thanks for the quick response Jason.
Tried your suggestion but it didn't work!
Do I have to save or shut the workbook first?

"Jason Zischke" wrote:

Try This :

Private Sub Worksheet_Activate()

Jason Zischke

"Mark Dullingham" wrote:

I recorde a simple macro to hide all the blank cells in a sheet and pasted
into the code of a command button as follws:

Private Sub CommandButton1_Click()
Range("B6:K425").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<"
End Sub

What I would like to do is have this macro apply when the sheet is opened
but I don't know what to enter after the 'Private Sub' bit instead of
CommandButton1_Click().

Can anyone help please.

Thanks a plenty in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Running a Marcro when sheet is opened

Mark Dullingham,

Yes you can the sub should run you open your workbook and that sheet is
active or when you switch between another sheet and back to the sheet that
has that sub in it.

Jason Zischke

"Mark Dullingham" wrote:

Thanks for the quick response Jason.
Tried your suggestion but it didn't work!
Do I have to save or shut the workbook first?

"Jason Zischke" wrote:

Try This :

Private Sub Worksheet_Activate()

Jason Zischke

"Mark Dullingham" wrote:

I recorde a simple macro to hide all the blank cells in a sheet and pasted
into the code of a command button as follws:

Private Sub CommandButton1_Click()
Range("B6:K425").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<"
End Sub

What I would like to do is have this macro apply when the sheet is opened
but I don't know what to enter after the 'Private Sub' bit instead of
CommandButton1_Click().

Can anyone help please.

Thanks a plenty in advance.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Running a Marcro when sheet is opened

Removed some code that was attached to another command button that reversed
the filter and all is chipper now.
thanks for taking the time

"Jason Zischke" wrote:

Mark Dullingham,

Yes you can the sub should run you open your workbook and that sheet is
active or when you switch between another sheet and back to the sheet that
has that sub in it.

Jason Zischke

"Mark Dullingham" wrote:

Thanks for the quick response Jason.
Tried your suggestion but it didn't work!
Do I have to save or shut the workbook first?

"Jason Zischke" wrote:

Try This :

Private Sub Worksheet_Activate()

Jason Zischke

"Mark Dullingham" wrote:

I recorde a simple macro to hide all the blank cells in a sheet and pasted
into the code of a command button as follws:

Private Sub CommandButton1_Click()
Range("B6:K425").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<"
End Sub

What I would like to do is have this macro apply when the sheet is opened
but I don't know what to enter after the 'Private Sub' bit instead of
CommandButton1_Click().

Can anyone help please.

Thanks a plenty in advance.



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
Protect Sheet with Marcro Conditional Formatting Excel Worksheet Functions 1 December 21st 05 07:40 PM
Marcro recroding/ stop Ikon not appearing in middle of excel sheet vishu Excel Discussion (Misc queries) 3 July 6th 05 11:37 PM
Marcro to copy sheet out of workbook mac Excel Programming 5 January 17th 05 10:02 PM
Running of a Macro when Workbook is opened Darin Kramer Excel Programming 2 December 14th 04 01:06 PM
Running a macro when a Wb is opened Marco Rodas Excel Programming 2 February 12th 04 03:44 PM


All times are GMT +1. The time now is 02:52 PM.

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

About Us

"It's about Microsoft Excel"