Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    running macros from a different file (excel97)

    I have a macro that opens a file and enters information into cells
    I did have it so it entered into a certain cell

    Workbooks.Open filename:=strTargetFile, UpdateLinks:=True
    Range("A1") = inputbox("type what needs to appear in the cell")

    But I have given the cell a name now, so the cell could be moved in the future but the text will still be written to it.


    Workbooks.Open filename:=strTargetFile, UpdateLinks:=True
    [Greeting] = inputbox("type what needs to appear in the cell")

    But as the name of the cell is on a different file from the macro the name is not recogised.
    So I thought I could put that line of code into the target file in the first place and then after opening the file get the macro to run.

    How do I get a Macro to run in a different file?

    Workbooks.Open filename:=strTargetFile, UpdateLinks:=True
    *RunTheMacroOnTheTargetFile*

    Is there another way of defining which file the named cells are in?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: running macros from a different file (excel97)

    You can use this instead of putting your code in the other workbook:

    Activeworkbook.Names("Greeting").ReferstoRange="ty pe what needs to appear in cell"
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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