+ Reply to Thread
Results 1 to 2 of 2

Macro to compare sheetname from one workbook with another and take actions depending if th

  1. #1
    Registered User
    Join Date
    03-31-2021
    Location
    As, Belgium
    MS-Off Ver
    O365
    Posts
    6

    Macro to compare sheetname from one workbook with another and take actions depending if th

    Hello,

    I am rather new to VBA scripting.
    I am now faced with a problem for which I cannot find the solution myself.
    I hope someone can help me.

    I have a source workbook and a target workbook.
    Each of the workbooks consists of several sheets.
    For the sheets of the source workbook that also exist in the target file, a range of must be copied from the sheet of the source file to the target file.
    The size of this range is always the same. The entire sheet cannot be copied, because the target workbook sheet contains formulas from a certain row and they must remain.
    For sheets from the source file that do not yet exist in the target workbook, a sheet with the same name must be created in the target workbook and the range of the source workbook sheet may be copied here.
    For Sheets in the target workbook whose name is a number and which do not exist in the source workbook, the range must be emptied.
    The range in both the source and target workbook sheets is rows 1 to 13.

    To be able to use this formula in several cases, I think it is best to enter the name of the source and target workbook in a certain cell in a sheet of the target workbook and then the contents of this cell in the VBA script assigned to specific variables.
    These variables can then be used in the loops to compare the sheet names of the source and target workbook.
    The VBA script would also be in the target workbook.

    I can make a loop in VBA.
    I think it's best to work with 2 loops for comparison.
    But assigning the names of the source and target workbook to a variable and then comparing the names of the sheets of these 2 variables and then linking the correct action to it doesn't work for me.
    Can someone help me with this.

    Thank you in advance.

    My best regards,

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Macro to compare sheetname from one workbook with another and take actions depending i

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. As you are still quite new here, I will do it for you this time: https://www.myonlinetraininghub.com/...a-match-or-not)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. [SOLVED] Multiple actions depending on content of cell.
    By Gingerwigshop in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-16-2021, 11:08 AM
  2. Replies: 4
    Last Post: 07-11-2018, 12:07 PM
  3. macro to copy from one workbook to another based on sheetname
    By mamachrissy1028 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-27-2017, 03:02 PM
  4. [SOLVED] Cell = sheetname get values from sheetname
    By soli004 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2014, 10:00 AM
  5. [SOLVED] Cannot get COMPARE fundtion to find differences then perform actions
    By Rabbitoh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-28-2013, 01:02 AM
  6. Using Sheetname in Vlookup as the sheetname for the array to lookup
    By OhioHsSport in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-05-2013, 09:18 PM
  7. Determining if sheet has existing data and further actions depending on it
    By xyz123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2008, 10:33 AM

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