ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macros on excel (https://www.excelbanter.com/excel-discussion-misc-queries/108902-macros-excel.html)

AJPG

Macros on excel
 
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

PCLIVE

Macros on excel
 
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.


"AJPG" wrote in message
...
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




stevebriz

Macros on excel
 
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

AJPG wrote:
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



sjk153

Macros on excel
 
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.

"AJPG" wrote:

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


AJPG

Macros on excel
 


"PCLIVE" wrote:

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.


"AJPG" wrote in message
...
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





AJPG

Macros on excel
 


"stevebriz" wrote:

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

AJPG wrote:
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




AJPG

Macros on excel
 


"sjk153" wrote:

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.

"AJPG" wrote:

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



All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com