+ Reply to Thread
Results 1 to 4 of 4

InputBox - If input has &, change & to ^&

  1. #1
    Registered User
    Join Date
    12-23-2011
    Location
    Rochester, NY
    MS-Off Ver
    Excel 2003
    Posts
    33

    InputBox - If input has &, change & to ^&

    Hello everyone,

    I've got something that may or may not be easy, I just don't know how to even begin attempting the code. I'm making an Excel spreadsheet that makes a batch file for a user based on dropdown boxes. Long story short, some dropdown boxes give the option to open specific websites in a new browser window. These websites allow login credentials in the URL so I have the macro asking for the username and password and then it puts the information in the URL, which it then puts into the batch file.
    The problem: Batch files and & signs don't get along, at least with what I need to do. I can put a ^ symbol in front of the & symbols in the URLs that I can see to fix them, however if a user has a password with an & symbol, that will cause the batch file to ignore that part of the website.

    The solution (at least the only one I can think of based on my research): Somehow make Excel substitute any & signs in a user's input in an inputbox with ^& before it prints it to the batch file.

    Is this possible? If so, how do I do it?
    Last edited by heather1209; 08-09-2012 at 09:17 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: InputBox - If input has &, change & to ^&

    have a look at using the =substitute() function, and see if that will give you what you need?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    12-23-2011
    Location
    Rochester, NY
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: InputBox - If input has &, change & to ^&

    Will that work for an inputbox in a macro?

    ---------- Post added at 08:54 PM ---------- Previous post was at 08:50 PM ----------

    Just did it with WorksheetFunction. It worked!!

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: [RESOLVED] InputBox - If input has &, change & to ^&

    glad to help and thx for the star

+ 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