Macros on excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'am sorry but i like to know how can activate a macro when i open a worksheet.
I have done a macro (ctrl+a) that do wat i want, but i must run it when i
open the worksheet.

Thanks in advance
Pinto Guimaraes
 
Alt+F11 to open the VB editor. Double-click on ThisWorkbook. Click
drop-down and select Workbook. Click second drop-down and select Open.
Then paste your code there.
 
You can do it through VBA
open the workbook
press "ALT" F11"
this opens the VB editor will open
Under the project explorer.
double click on "this workbook " and then in the code window
paste as below ...you need to replace NameOfMacro with your Macro name
go back to excel and save the workbook.
And next time you open it - it will ask to enable macros ...so say
Enable
and then the macro will run.

Private Sub Workbook_Activate()

Call NameOfMacro

End Sub
 
Try this-- Open the Visual Basic Editor by going to the 'Tools' menu, open
'Macros...', and select Visual Basic Editor.

On the left side of the VBE you will see the project window (will list the
sheets in the current workbook).
1. Double Click 'ThisWorkbook' from the project window
2. At the top center, you will see a drop down list (General), Select Workbook
- You should now see the following:
Private Sub WorkBook_Open()

End Sub
3. Enter a statement to call your macro once the workbook is opened:
Private Sub WorkBook_Open()
Call YourMacroNameHere
End Sub

YourMacroNameHere = the name you gave your macro. Now when you open the
workbook the macro will run.
 
PCLIVE said:
Alt+F11 to open the VB editor. Double-click on ThisWorkbook. Click
drop-down and select Workbook. Click second drop-down and select Open.
Then paste your code there.
 
stevebriz said:
You can do it through VBA
open the workbook
press "ALT" F11"
this opens the VB editor will open
Under the project explorer.
double click on "this workbook " and then in the code window
paste as below ...you need to replace NameOfMacro with your Macro name
go back to excel and save the workbook.
And next time you open it - it will ask to enable macros ...so say
Enable
and then the macro will run.

Private Sub Workbook_Activate()

Call NameOfMacro

End Sub
 
sjk153 said:
Try this-- Open the Visual Basic Editor by going to the 'Tools' menu, open
'Macros...', and select Visual Basic Editor.

On the left side of the VBE you will see the project window (will list the
sheets in the current workbook).
1. Double Click 'ThisWorkbook' from the project window
2. At the top center, you will see a drop down list (General), Select Workbook
- You should now see the following:
Private Sub WorkBook_Open()

End Sub
3. Enter a statement to call your macro once the workbook is opened:
Private Sub WorkBook_Open()
Call YourMacroNameHere
End Sub

YourMacroNameHere = the name you gave your macro. Now when you open the
workbook the macro will run.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top