Hi Jason and team, i have a question on the how to write up a macro code that enable me to replace a few values.

For example, i would like to replace MAL as Malaysia / IND as Indonesia / CAM as Cambodia. Is there a way to loop and use IF condition?

What i think of is to read value of example cell A2, and loop with IF(read value=”MAL”,”Malaysia”,””). Is it okay to have a few IF condition in the same loop?

    1 Response to "Looping in Macro for replacing a few values"

    • admin

      Hi Joanna,

      Yes, it is possible. They are called nested IF, similar to nested IF using Excel formula. The setup can be like this:

      IF read_value = “MAL” then
      ‘code to replace value with “Malaysia
      Else
      IF read_value = “IND” then
      ‘code to replace value with “Indonesia”
      Else
      ‘some thing else
      End IF
      End IF

Leave a Reply