+ Reply to Thread
Results 1 to 11 of 11

Macro Multiple Find and Replace with a formatted cell in Excel 2010

  1. #1
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Macro Multiple Find and Replace with a formatted cell in Excel 2010

    Hi Guys,

    Thanks for the support provided by your forum that I've just joined

    I'm using with good profit a macro that replace value in column A if found in column C with a value in column B.

    Now I would need to have the destination cell for the replaced value be formatted with green fill.

    Macro is the one below, could you please suggest how to add the green fill format for the replaced values?

    PHP Code: 
    Sub ReplaceText() 

    For 
    Each vCell In Range("A2:A200").Cells 

    Columns
    ("C:C").Cells.Replace What:=vCellReplacement:=vCell.Offset(01).ValueLookAt:=xlWhole
            SearchOrder
    :=xlByRowsMatchCase:=FalseSearchFormat:=False
            ReplaceFormat
    :=False 

    Next vCell 
    End Sub


    Many thanks in advance!

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    Maybe?

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    hi thanks for the reply,

    I think what you are seuggesting must be added to my macro, true?
    where exactly to insert this addictional part of the code ?
    Please be patient i'm totally new of macros
    Thanks again

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    It's been awhile since I wrote this. However, I think I was suggesting a replacement code, for what you had. Try it as a replacement first too see if it does what you want.

  5. #5
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    Hi John,

    sorry for the long pause but I'm just now going back to this job and I would need your code again.

    No it doesn't...actually it replaces values in column "A" instead of "C"...and it entirely formats the column "A".

    Let's stick to the fist code that actually worked like a charm!!
    what I need is that in column "C" the replaced value to be somehow highlighted please (no matter if by red fonts or green interiour!)

    THANKS!

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    Try:

    Please Login or Register  to view this content.
    This code will work as well as the first. But it's a matter of understanding what you require. Your statement:

    "I'm using with good profit a macro that replace value in column A if found in column C with a value in column B."

    is not clear of what you require. I just realized that this thread is over a year old?
    Last edited by JOHN H. DAVIS; 01-30-2014 at 11:48 AM.

  7. #7
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    yes the thread is very old as I said I'm sorry about that...

    the fist code ï posted did exactly what I needed :

    Please Login or Register  to view this content.
    it means, Macro searches Colomun C for values in common with Column A and if those are found they are replaced with the corrispondent value in B.
    in the above example macro finds value "X" in C and replaces it with the corrispondent value in B: X1

    All I need is the replaced values in C to be highlited so I can easily find them in a long list.

    I hope I have been clearer now and super thanks for your help

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    Did you test the code in Post #6? In your after example should row 2 Column C be K1? Or just K?

  9. #9
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    K1 because, macro found K in Column C and replaced it with K1 as wanted.


    code in post 6 doesn't work properly infact only row 1 and 4 were replaced, while there were much more expected to be.
    Please consider that columns A&B can be much shorter then C but still the replacement must cover all C values if need be :


    PHP Code: 
    Before code in post 6

    1    1A    1
    1    1A    1
    3    3A    2
    2    2A    3
    4    4A    4
               4
               4
               7
               3
               1 

    PHP Code: 
     After code in post 6,please note that the replaced value were actualy highlighted in green and that is very good!

    1    1A    1   Skipped
    1    1A    1A  Correct
    3    3A    2   
    (this should have been 2A according to row for in colum Bdoesn't matter if the value"2" has been found in a different row.)  
    2    2A    3   (this should have been 3A according to row for in colum B, doesn'
    t matter if the value"3" has been found in a different row.)
    4    4A    4A  Correct
               4   WRONG macro must cover all colomun C always referring to what we have in column A
    &B pleaseshoudl have been 4A
               4   same 
    as above
               7   correct but only because macro didn
    't take it into any account
               3   WRONG macro must cover all colomun C always referring to what we have in column A&B please, shoudl have been 3A
               1   same as above it should have been 1A according to row 1 in coloumn A&B please.[/COLOR] 
    Jhon thanks again , but in my opinion we shoudl try to use the code I posted and starting from that one adding the only formatting command to highlight the reaplced value in C.

    THANKS!
    Last edited by isasa74; 01-31-2014 at 05:21 AM.

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    Can you attach a sample file to test on?

  11. #11
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Macro Multiple Find and Replace with a formatted cell in Excel 2010

    sure! here you are

    thanks!
    Attached Files Attached Files
    Last edited by isasa74; 01-31-2014 at 08:04 AM.

+ 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