PDA

View Full Version : Excel Macro that creates an Auto Macro



Jonsby
10-26-2009, 06:22 AM
Hi all,

I'm still new to the whole VBA scene so I'm not too sure how it all works but I was aiming to create a macro that would be located within my Personal.XLSB spreadsheet and whenever I run it, it creates an automated process within the workbook.
I thought of a macro that creates a line of commands within "ThisWorkbook" and sets it as e.g. Workbook_SheetActivate. I'm not sure if this is possible or if there are any other possible ways of doing this but any help will be greatly appreciated.

Thank you.

Bob Phillips
10-26-2009, 06:51 AM
I would suggest that you have application events rather than writing to other workbooks.



Public WithEvents App As Application

Private Sub App_SheetActivate(ByVal Sh As Object)
'your code here
End

Private Sub Workbook_Open()
Set App = Application
End Sub


This is workbook event code.
To input this code, right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code