+ Reply to Thread
Results 1 to 4 of 4

Find and replace string in VBA Sub

  1. #1
    Registered User
    Join Date
    02-24-2015
    Location
    Albuquerque, USA
    MS-Off Ver
    2013
    Posts
    10

    Find and replace string in VBA Sub

    Fellow Forum Members,
    can someone out there please help me out with a VBA script that will do the following:

    Open the Code in UserForm1 Private Sub UserForm_Initialize()
    Find the string "ABC" and replace it with "123"

    Thanks in advance
    Detlef

    Please Login or Register  to view this content.
    Detlef Heun
    www.aircraft-trust.com

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,826

    Re: Find and replace string in VBA Sub

    Why don't you declare a Global variable and put the sheet name in that?

    Please Login or Register  to view this content.
    Then, rather than use:
    Please Login or Register  to view this content.
    use
    Please Login or Register  to view this content.
    Then you can set it to an initial value of "ABC" wherever you want, and change it to "123" somewhere else.

    No need to write code to change code.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-24-2015
    Location
    Albuquerque, USA
    MS-Off Ver
    2013
    Posts
    10

    Re: Find and replace string in VBA Sub

    Hi TMS,
    Thanks for your response.
    But I'm a Newbie in VBA and don't know what you mean, or how to do it.

    I have different products and whenever I choose another Product I need only to replace the "ABC"
    with the name of my worksheet.

    This what I want to do with my private sub command.

    Maybe it is more complicate, but I understand what i'm doing.

    If you can give me the code for this, I would be more than happy.

    Thanks a lot
    Detlef

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,826

    Re: Find and replace string in VBA Sub

    Maybe it is more complicate, but I understand what i'm doing.
    Yes it is and no you don't ... otherwise you wouldn't be asking the question.

+ 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. [SOLVED] Find and replace with exact string
    By carrie.cllek in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-27-2013, 04:02 PM
  2. find, replace and rearrange a string
    By lillianng in forum Excel General
    Replies: 3
    Last Post: 06-21-2013, 07:19 PM
  3. [SOLVED] Find a string by VBA Regular Expression and replace a part of that string
    By taps in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2013, 11:08 AM
  4. Find and Replace text within string
    By Soulbringer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-22-2012, 12:30 PM
  5. [SOLVED] How to Find and Replace only if critera is at the end of the string?
    By windcloud2 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-02-2012, 02:39 PM
  6. Find/Replace Characters in a string
    By Light Pail in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2010, 08:08 PM
  7. [SOLVED] Find / Replace in a string
    By Basu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2006, 10:55 AM
  8. Find and Replace in a DDE string!!!
    By Mark Dullingham in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2006, 08:20 PM

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