+ Reply to Thread
Results 1 to 4 of 4

VBA Replace

  1. #1
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    VBA Replace

    Hello,

    I have cells with a1 + 1, a2 + 1 etc. But i have like a million cells with this formula. Now i would like to change the sum from + 1 to + 6, but i would do this with a VBA code (maybe replace). But otherwise excel doesn't keep working.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: VBA Replace

    Hello,

    You may be able to do that with a find and replace operation rather than VBA.

    Hit Ctrl-H to open the Find and Replace dialog.
    In the "Find what" box enter "+1" (without the quotes)
    In the "Replace with" box, enter "+6" (without the quotes)
    Ensure that the "Look in" drop-down is set to "Formulas"
    Hit "Replace All"

    To avoid this situation in the future, you could create a named formula for the number you want to add. Use the Name Manager and create a name. Call it, for example "AddMe" and in the "Refers to" box enter the number, i.e. 6.

    Now do a find and replace. With your original formula that has the +1, find the +1 and replace it with +AddMe.

    The next time you need to change the value, open the Name Manager, edit the AddMe name and change its value. Each formula that refers to the name "AddMe" will then use the new value you specified.

    Let me know if this helps.

    cheers, teylyn

  3. #3
    Forum Contributor
    Join Date
    11-06-2012
    Posts
    139

    Re: VBA Replace

    Thnx for your input.

    The replace all i tried, but i couldn't be done in one time. Excel didn't like that.

    That's why i would like to have that replace formula in vba.

  4. #4
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: VBA Replace

    You can use the Record Macro feature and try to record the Find & Replace feature, then perhaps tweak the code for better performance.

+ 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 to not replace characters found as wildcards
    By sabutler4 in forum Excel General
    Replies: 4
    Last Post: 07-03-2013, 06:48 PM
  2. Multiple Find and Replace to replace a list of strings
    By WalterP34 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2011, 07:41 PM
  3. Find, and replace but copy cells before replace
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2007, 08:16 AM
  4. find and replace - replace data in rows to separated by commas
    By msdker in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-14-2006, 08:10 PM
  5. [SOLVED] How can I use replace(alt+H) for mutiple items needing replace
    By Gery in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 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