+ Reply to Thread
Results 1 to 16 of 16

Find and Replace in VBA does not work

  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Find and Replace in VBA does not work

    Hi,

    In a userform I created a listBox, added items to it and then a macro, depending on the value I will select, should make replacements. I recorded the macro Find/replace (the msgBox works after the replacements. Means it jumps over the code).

    Here is the beginning of the macro (is a If/elseif after):

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Find and Replace in VBA does not work

    Are you find/replacing within formulas?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    Hi Norie,

    Yes it is to replace inside formulas

    pit

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Find and Replace in VBA does not work

    Does this make a difference?


    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    Unfortunately it does not change,

    pit

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Find and Replace in VBA does not work

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  7. #7
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    I am getting closer to the problem. I created a loop to see how the Find and Replace behave once VBAed

    I spotted what Excel "doesn't like". It is actually the chain of characters to find and replace into the formulas.

    I highlighted in red the problem. If I change the characters in red by just "APAC" eg, it will work fine...

    I did not figure out still how to resolve the issue

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Find and Replace in VBA does not work

    Your original code, with the minor changes I suggested, worked for me just fine.

    If you just want to replace LATAM with APAC just use this.
    Please Login or Register  to view this content.
    That works for me.

  9. #9
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    With what is in red above, will not work. This is my issue. I don't want to change just a word. I need to change the piece of formula.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Find and Replace in VBA does not work

    Strange, what I posted does change formulas.


    The only difference between this, "$R:$R;""LATAM""", and this, "$R:$R;""APAC""", is APAC.

  11. #11
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    Please refer to the initial post (which is still only an extract). I need to update the columns as well in the formulas. This excel workbook will deal with all regions over the world.

    I would still value the answer as to how to update the part of the formula in red characters above

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Find and Replace in VBA does not work

    It really would help to see some sample data.

    I think the problem could be something to do with the quotes you are using.

  13. #13
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    This is a typical formula in the cell for which I would like the code to work:

    In red is the part I want to change (same for column R and column Q).

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Find and Replace in VBA does not work

    What should it be replaced with?

  15. #15
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    for example:

    $R:$R;"LATAM"

  16. #16
    Registered User
    Join Date
    04-09-2013
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Find and Replace in VBA does not work

    Hi Norie, everyone,

    Norie, thank you so far for your time spent trying to solve the issue. I thought maybe it could help to seek further heads

    Would there be someone who could resolve this? Or even help finding a way to trick Excel.

    Thank you
    pit

+ 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