+ Reply to Thread
Results 1 to 15 of 15

Wildcards

  1. #1
    Registered User
    Join Date
    12-22-2011
    Location
    Massachusetts
    MS-Off Ver
    Excel 2003
    Posts
    12

    Wildcards

    I have a macro that pulls information from another spreadsheet that is generated as needed. The file that's generated is called output[x], where the x is a number between 1 and 9.

    The line I'm currently using is, Windows("output[1].csv").Activate. But then I realized the the number may change (is doesn't always change, just sometimes). Is there a wildcard character I can use to replace that 1 with?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards

    One way:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-22-2011
    Location
    Massachusetts
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Wildcards

    Quote Originally Posted by shg View Post
    One way:
    Please Login or Register  to view this content.
    I tried to copy that in but it didn't work. Here's the whole macro.

    Please Login or Register  to view this content.
    That's the macro as is, and it works if the generated workbook is output[1]. But again, sometimes it comes up as ouput[2], output[3], etc.
    Last edited by TechTed; 12-27-2011 at 04:44 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.

  5. #5
    Registered User
    Join Date
    12-22-2011
    Location
    Massachusetts
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Wildcards

    Quote Originally Posted by shg View Post
    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Sorry. Won't happen again.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards

    Thanks.

    What's the name of the worksheet in "Balance Transfers" that gets pasted to?

  7. #7
    Registered User
    Join Date
    12-22-2011
    Location
    Massachusetts
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Wildcards

    Reallocation Requests

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards

    What's the name of the worksheet in output.csv?

    EDIT: Never mind, back in a minute ...
    Last edited by shg; 12-27-2011 at 05:17 PM.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    12-22-2011
    Location
    Massachusetts
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Wildcards

    I really appreciate the assistance. I just tested it out and I keep getting a message that, No workbook like "output[#]" is open! I tested it with ouput[1] open, and also with output[2].

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards

    Ah -- the brackets get changed to parens by Excel:

    Please Login or Register  to view this content.

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wildcards

    Hello SHG,

    You need to escape the left bracket in the Like statement...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Wildcards

    I take your point about the Like statement Leith (thank you), but in the workbooks collection, the filename of output[1].csv is actually output(1).csv

  14. #14
    Registered User
    Join Date
    12-22-2011
    Location
    Massachusetts
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Wildcards

    Quote Originally Posted by shg View Post
    Ah -- the brackets get changed to parens by Excel:

    Please Login or Register  to view this content.
    That still isn't working. I did just notice that in workbook output[#].csv the worksheet is called .csv]output(#). Might that make a difference in your suggestion?

  15. #15
    Registered User
    Join Date
    12-22-2011
    Location
    Massachusetts
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Wildcards

    I doubled up on the brackets as suggested by Leith and now it works. Thanks so much you two.

+ 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