Results 1 to 4 of 4

VBA Replace problem

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    826

    VBA Replace problem

    I have a bigger macro which after the calculations have been done, needs to do a Text to column on that column of the formulas.
    Before I do this text to column I first convert all the formulas to values except the first formula (want to keep that for reference).

    My excel uses ' ; ' in formulas and after the text to column the formula is changed to be separated by ' , '.
    Now of course that formula will not work anymore.

    So I wanted to change it all back again with a simple replace in VBA.
    But this is not working somehow.

    Strange thing is that even when I record the macro i will not work when I use that recorded macro.

    I attached a workbook. It has 2 codes (1 of 2 is blocked).
    Both I would expect to work but they don't.
    The blocked one is the one I recorded.

    Sub tst()
        'Correct Formula in U
        Range("A2").Replace What:=",", Replacement:=";", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        Range("A2").Replace What:=",", Replacement:=";", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
    
    '    ActiveCell.Replace What:=",", Replacement:=";", LookAt:=xlPart, _
    '        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    '        ReplaceFormat:=False
    '    Cells.Find(What:=",", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
    '        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    '        , SearchFormat:=False).Activate
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find and Replace problem
    By mark99th in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2012, 02:06 PM
  2. Problem with Find and Replace
    By mjhill01 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  3. Problem with Find and Replace
    By Dave Peterson in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 09:05 AM
  4. [SOLVED] Problem with Find and Replace
    By mjhill01 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  5. [SOLVED] Problem with Find and Replace
    By mjhill01 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. [SOLVED] Problem with Find and Replace
    By mjhill01 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  7. Replace Text problem
    By ramonacv in forum Excel General
    Replies: 0
    Last Post: 02-03-2005, 09:42 PM
  8. problem with replace (VB)
    By Sieto Verver in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2005, 09:06 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