+ Reply to Thread
Results 1 to 5 of 5

Wildcard for Different Sheet names

  1. #1
    Registered User
    Join Date
    03-28-2012
    Location
    Missouri
    MS-Off Ver
    Excel 2007
    Posts
    30

    Wildcard for Different Sheet names

    I have a macro that I wrote for a specific spreadsheet and I now want to use that macro for other sheets that contain the same data, but have a different worksheet name. I want the macro to ignore the first to characters of the sheet name and I am unsure how to do this.

    Here is the specific part of the macro where the sheet name comes into play. I would like the macro to ignore the sheet name all together or just the first 2 characters, because that is the only difference between the speadsheets that I will run it against.

    Cells.Select
    ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
    Clear
    ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
    Add Key:=Range("A2:A34239"), SortOn:=xlSortOnValues, Order:=xlAscending, _
    DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
    Add Key:=Range("H2:H34239"), SortOn:=xlSortOnValues, Order:=xlAscending, _
    DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort
    .SetRange Range("A1:S34239")
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Wildcard for Different Sheet names

    Please use code tags when posting. Refer too Forum Rule No. 3. Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Wildcard for Different Sheet names

    Change Worksheets("FW POG CONVERSION REFRESH FILE") to ActiveSheet and the code will run on whicheever sheet is currently active.
    If posting code please use code tags, see here.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,705

    Re: Wildcard for Different Sheet names

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    03-28-2012
    Location
    Missouri
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Wildcard for Different Sheet names

    Here is the code
    Please Login or Register  to view this content.
    Last edited by alansidman; 12-09-2014 at 11:53 AM.

+ 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] Wildcard for Different Sheet names
    By eagle670 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-14-2014, 11:15 AM
  2. [SOLVED] Create an Array which has Sheet Names excluding a Few Sheet Names to be used in a MACRO
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-29-2013, 03:24 PM
  3. Replies: 2
    Last Post: 01-24-2013, 04:56 PM
  4. Create a Formula That Uses a Wildcard for Multiple Workbook Names
    By squirl1899 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-04-2012, 03:34 PM
  5. Getting a list of Sheet Names by excluding certain Sheet Names instantenously..
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-09-2012, 12:16 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