Consulting

Results 1 to 2 of 2

Thread: Excel Macro that creates an Auto Macro

  1. #1

    Excel Macro that creates an Auto Macro

    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.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I would suggest that you have application events rather than writing to other workbooks.

    [vba]

    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
    [/vba]

    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
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •