+ Reply to Thread
Results 1 to 3 of 3

How do I use InStr to find a '-' in the filename?

  1. #1
    Registered User
    Join Date
    07-07-2013
    Location
    Milwaukee, Wi
    MS-Off Ver
    Excel 2013
    Posts
    5

    How do I use InStr to find a '-' in the filename?

    Hey all,

    I'm trying to find the '-' in a file name using InStr. Here's the code:

    Please Login or Register  to view this content.
    I keep getting a value of 0. Shouldn't I get a 9? I think I'm missing something.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: How do I use InStr to find a '-' in the filename?

    Take out the quotes from "MyFileName" within the InStr method, like so:
    Please Login or Register  to view this content.

    Otherwise it is performing the InStr method on the string "MyFileName" instead of the variable MyFileName (which evaluates to the string "Operator-Joe.xlsm")
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    07-07-2013
    Location
    Milwaukee, Wi
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: How do I use InStr to find a '-' in the filename?

    That did the trick! Thanks for the help.

+ 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