+ Reply to Thread
Results 1 to 2 of 2

Macro to replace known static by entering only replacement text input box

  1. #1
    Registered User
    Join Date
    11-26-2017
    Location
    USA
    MS-Off Ver
    10
    Posts
    7

    Macro to replace known static by entering only replacement text input box

    Hi all!

    Looking for some help with a macro to replace/populate text that is already in a worksheet with user input without the user having to input the known text, just the replacement text.

    I have a worksheet with multiple cells containing strings of static text that I am using as a template.

    For instance, one cell may read "APEX "State Abbreviation" "City" Local Team "Team Number"

    The words "State Abbreviation", "city", and "team number" appear multiple times throughout the document and I'd like to replace each one with the same input.

    I was using the below, but am stuck on how to either hide that first input box or enter the known text string phrases as replacement code.

    Any help would be greatly appreciated!!!


    Sub rpl()
    Sheets("sheet1").Select
    What = InputBox("Copy "State Abbreviation" into the box")
    repl = InputBox("State Abbreviation")
    Cells.Replace What:=What, Replacement:=repl, LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Sub rpl()
    Sheets("sheet1").Select
    What = InputBox("Copy "City" into the box")
    repl = InputBox("City")
    Cells.Replace What:=What, Replacement:=repl, LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Sub rpl()
    Sheets("sheet1").Select
    What = InputBox("Copy "Team Number" into the box")
    repl = InputBox("Team Number")
    Cells.Replace What:=What, Replacement:=repl, LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    End Sub

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Macro to replace known static by entering only replacement text input box

    Do both:
    1) try:
    Please Login or Register  to view this content.
    2) 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.

    Click on Edit to open your thread, then 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
    Best Regards,

    Kaper

+ 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. Macro for same text replacement on multiple sheets of a workbook
    By naragam in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-07-2017, 10:50 AM
  2. Outlook Text Replacement Macro
    By 7hrowdown in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2013, 10:14 AM
  3. Excel VB Macro- Literal Text Replacement
    By atari911 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2012, 09:03 PM
  4. Macro to calculate the percent difference after entering an input
    By hydronicengr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2012, 08:33 PM
  5. Using text box input to lookup number and replace based on user input into new column
    By harl3y412 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2011, 03:15 PM
  6. Using macro to input static date
    By Dark Pelican in forum Excel General
    Replies: 8
    Last Post: 07-01-2011, 05:24 AM
  7. [SOLVED] Use a static set of data for input into a macro
    By cdb in forum Excel General
    Replies: 2
    Last Post: 03-16-2006, 11:55 AM

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