How to call a Macro from another Excel workbook | MS Excel VBA Tutorial

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024
  • Buy Me a Coffee? www.paypal.me/...
    Your donation will help me to make more tutorial videos!
    Sometimes you may want to run a macro from another Excel workbook. Or maybe you have an Excel workbook which you store all your macros and you want to use some of those macros without redoing the same work.
    In this video I will show you how to call a macro from a other Excel workbook.
    Visit my website
    LearnDataAnaly...

Комментарии • 13

  • @billiexxx3671
    @billiexxx3671 2 года назад

    Hi Jie! Thank you so much even after four years of posting this until now this helped me currently with my problem! Thank you again!!

  • @AnandSinghVentures
    @AnandSinghVentures 4 года назад

    Thanks 👍 This worked

  • @chenchristina5137
    @chenchristina5137 4 года назад

    Hi! Is there any code that I do not need to change the file path in the code. Instead, I can modify the file path directly in worksheet. I tried this one: "Set Macroworkbook = Workbooks.Open(Sheets(Index).Range("J16").Value)" but it says 'subscript out of range'. Thanks!

  • @jaspreet8648
    @jaspreet8648 5 лет назад

    Hi Dinesh,
    Hope you are doing good. Thanks for the above program as I was looking for such logic. However, I am facing an issue. I am calling the macro from another workbook using the exact lines of code as presented by you. But I am getting "Runtime error: 9 Subscript Out of Range error" My other macro is not just a Debug Print or Msgbox button. But it actually creates a Named range table and then performs couple of logic. So my question is that does this feature of calling the macro from another workbook, work only for simple Debug Print or Msgbox button etc.
    P.S: My other macro runs absolutely smooth without any issue when I run them separately.
    Thanks,
    Jaspreet

  • @chenchristina5137
    @chenchristina5137 4 года назад

    Hi, I have a problem when I step into the 'create a reference to the chart' part. It keep saying that cannot find the item, I don't know why the bugs happen. Because my target chart sheet exists, the name is correct... Thanks!

  • @ValmisFilm
    @ValmisFilm 4 года назад

    hi. VBA question - is it possible to detect, if another file was opened? I mean I have my file A open,I open File B - and File A would detect through VBA that another file was opened. The problem is, that if you open file B, then file A will not be active anymore and no macros have a connection to file B.

    • @jiejenn
      @jiejenn  4 года назад

      Give this tutorial a try. ruclips.net/video/cbOQpXf96Pc/видео.html

  • @satyenpurohit3947
    @satyenpurohit3947 5 лет назад

    Sir, i want to run macro in file 1 but its control button shall be in file 2, say once we give command to run macro in file 2, the macro of file 1 shall run. How can we do tha

    • @nsanerydah
      @nsanerydah 4 года назад

      Good Morning Sir,I had to do something similar to what I think you are talking about. I have a macro CommandButton1_Click(). Once I completed that macro, I made a macro below like such:Public Sub ForceClickOnButtonCommandButton1()
      Call CommandButton1_Click
      End SubThen I have a macro that "clicks" the button when I open the file (it opens a different file and extracts data and imports into the file I'm working on) as such:Sub Workbook_Open()Application.ScreenUpdating = FalseSheets("ImportSData").Activate
      'Use the following line to disable/enable the auto import function
      Call Sheets("ImportSData").ForceClickOnButtonCommandButton1Sheets("ImportWData").Activate
      'Use the following line to disable/enable the auto import function
      Call Sheets("ImportWData").ForceClickOnButtonCommandButton2Application.ScreenUpdating = TrueSheets("TransposeData").SelectEnd SubNot sure if this is something you could use, but it is a mash-up of a bunch of other RUclips'rs work modified to fit my needs.

    • @nsanerydah
      @nsanerydah 4 года назад

      Sorry about the formatting. it's not how I typed it. Trying again.Good Morning Sir,I had to do something similar to what I think you are talking about. I have a macro CommandButton1_Click(). Once I completed that macro, I made a macro below like such:Public Sub ForceClickOnButtonCommandButton1()
      Call CommandButton1_Click
      End SubThen I have a macro that "clicks" the button when I open the file (it opens a different file and extracts data and imports into the file I'm working on) as such:Sub Workbook_Open()Application.ScreenUpdating = FalseSheets("ImportSData").Activate
      'Use the following line to disable/enable the auto import function
      Call Sheets("ImportSData").ForceClickOnButtonCommandButton1Sheets("ImportWData").Activate
      'Use the following line to disable/enable the auto import function
      Call Sheets("ImportWData").ForceClickOnButtonCommandButton2Application.ScreenUpdating = TrueSheets("TransposeData").SelectEnd SubNot sure if this is something you could use, but it is a mash-up of a bunch of other RUclips'rs work modified to fit my needs.