Results 1 to 6 of 6

Thread: Excel macros

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Arlington, TX
    Posts
    60

    Excel macros

    I've been working with Visual Basic for a while, but a few days ago I started working with VBA in Excel, and I've run into a small problem...I got my code working the way I want it to, but it's for a monthly report, and there may be people who don't know anything about programming working the report and needing to run the code. Because of this, I want to be able to run the code from any Excel workbook. Unfortunately, as far as I know the only way to run a macro from another workbook is if the workbook with the macro is open. Is there any way to run a macro from a workbook that isn't actually open, or will I have to write up some instructions for how to copy the code to the new workbook?

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Excel macros

    You will be able to open and control the other workbook from the original one..

    It really depends on what you are trying to achieve.. Is this through a userform or button? and what needs to be done..

    example code

    VB Code:
    1. Workbooks.Open "Other Workbook"
    2.   Workbooks.Add
    3.   ActiveWorkbook.Range("A1").Select

    There's load I can assist with as VBA for Excel was my introduction to Visual Basic 7 years ago..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Arlington, TX
    Posts
    60

    Re: Excel macros

    Actually, I need the second workbook to be able to run a macro that was created in the first workbook whether the first one is open or not. It would be ideal if it didn't require any code, because of the non-programmers working with the report.

  4. #4
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Excel macros

    Use a template workbook with the macro already coded up inside, and then save it as a different workbook from the first workbook
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Arlington, TX
    Posts
    60

    Re: Excel macros

    As long as everyone knows not to delete or save over the template, that should work perfectly! Thanks.

  6. #6
    Addicted Member
    Join Date
    Jan 2005
    Posts
    138

    Re: Excel macros

    Creating an addin would do the trick, it's more work though.

Posting Permissions

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



Click Here to Expand Forum to Full Width