+ Reply to Thread
Results 1 to 8 of 8

Need to change a recorded macro/use wildcards

  1. #1
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Need to change a recorded macro/use wildcards

    Hello,

    I have referenced an Excel 2007 spreadsheet called Consolidated 2012-08-18 to 2012-08-24 V2 but I just realized that the name of the sheet I need to reference isn't always going to be the same. It will however start with Consolidated 201x-xx-x to 201x-x-x where the X's are the characters that will change based on the date of the week as well as it could have a version number at the end or it could be blank at the end.

    Am I able to step into the macro and replace the characters that will change with wildcards? If so, could somebody give me a little explanation as to how? I do not fully understand writing macros, I usually just record them.

    Thanks!

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Need to change a recorded macro/use wildcards

    Quote Originally Posted by Wheelie686 View Post
    Hello,

    I have referenced an Excel 2007 spreadsheet ...Am I able to step into the macro
    Your question is just a little vague.

    If you are manipulating the data ON the sheet you're talking about changing, then just use ActiveSheet. If this page is indeed a 'reference' page, then we'll need to see more code.
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Need to change a recorded macro/use wildcards

    I have two spreadsheets open. The first one is called Consolidated 2012-08-18 to 2012-08-24 V2 and the 2nd spreadsheet reads from that spreadsheet and pulls specific information. The problem I have is the macro I created reads the exact title and what I need it to do is still be able to read it even if I change the name of the first spreadsheet. The title is manually changed depending on the date.

    The following is a copy of a macro I call "CHSI"

    Please Login or Register  to view this content.
    Last edited by Cutter; 08-16-2012 at 10:14 PM. Reason: Added code tags

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Need to change a recorded macro/use wildcards

    @ Wheelie686

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  5. #5
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Need to change a recorded macro/use wildcards

    Try this.

    Put this code in the 'template' workbook in a standard module.

    When you run it, it will ask for 'source file'. This is the file it will copy FROM.

    Please Login or Register  to view this content.
    Last edited by Tinbendr; 08-17-2012 at 10:10 AM.

  6. #6
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Need to change a recorded macro/use wildcards

    When I do that it gives me a Debug error and when I open VB it says If SrcFN <> False Then

  7. #7
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Need to change a recorded macro/use wildcards

    Try

    if SrcFN <> "False" Then

  8. #8
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Need to change a recorded macro/use wildcards

    That just caused another debug error. Can I not just replace the characters that will change with some sort of wildcard character?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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