+ Reply to Thread
Results 1 to 2 of 2

Call Macro X if the sheet name contains "...", otherwise Call Macro Y

  1. #1
    Registered User
    Join Date
    01-13-2022
    Location
    Motta di Livenza, Italy
    MS-Off Ver
    Excel 2016
    Posts
    25

    Call Macro X if the sheet name contains "...", otherwise Call Macro Y

    Hello there!

    I'm working on a macro that would allow me to run automatically one among other macros that I already created, depending on the name of a worksheet contained in the workbook.

    The thing is, I usually download 2 kinds of files from a platform, which require different macros and don't have the same name: one starts with "global-mis", the other with "sherlock". Besides, the respective names have a number associated, which changes depending on how many times you retrieve the file every day (the associated number increases).

    When I download one of these this files, I then move the sheet to a workbook where I keep all my macros: in this workbook, after having moved the relevant downloaded file into it, I'm working on the following code:

    Dim ws As Worksheet
    For Each ws In Worksheets
    If ws.Name Like "global-mis" Then Call Macro1
    If ws.Name Like "sherlock" Then Call Macro2

    Next ws

    However, it ain't working. Every time I run it nothing happens. Do you have any suggestion please?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,517

    Re: Call Macro X if the sheet name contains "...", otherwise Call Macro Y

    Maybe:
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Recorded Macro "Invalid procedure or call argument" Error
    By lilit2222 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2020, 05:04 AM
  2. Call "Private Sub Workbook_BeforeClose" from a macro
    By FAdvisor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2020, 06:39 PM
  3. I am getting this error by below macro "Invalid procedure call arguement" please help
    By shoaibaligwl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2017, 09:39 AM
  4. [SOLVED] Protecting worksheet but allowing "forms" button to still call a macro
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2014, 05:58 PM
  5. [SOLVED] Jumping to the macro from the "Call" line while viewing the code
    By Alexander_Golinsky in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2013, 05:23 AM
  6. Macro that simulates a "call ticker" for sales
    By hysterical.useless in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2012, 12:34 AM
  7. Call a sub statement in "Personal Macro Workbook" from "ThisWorkbo
    By QC Coug in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2005, 03:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1