Trim the recorded macro

  • Good Day,


    Please assist to trim the recorded macro.




    A table consist of same header, I'm replacing the header names with find and replace vba code.


    Ignoring the two matches and Replacing 3rd match, 4th match, 5th match as Apple,Mango and Orange respectively.


    Kindly refer to the attached file.


    -Anna

  • Try this


    Code
    With ActiveSheet.UsedRange.Cells
        .Replace What:="Fruit", Replacement:="Apple", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
            End With
    End Sub
  • Try:

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Replace this line of code:

    Code
    v = Array("Fruit", "Fruit", "Apple", "Mango", "Orange")

    with this line:

    Code
    v = Array("Fruit", "Fruit", "Apple", "Fruit", "Orange")

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • You are very welcome. :)

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!