Replacing values separated by commas

mliang87

New Member
Joined
Feb 19, 2013
Messages
7
Hello all,

Currently I have written a macro that converts values in a cell to values mapped in another tab list.

My code is:
Code:
Sub DataFormatPR()
Dim PremiumType
Set PremiumType = Sheets("PremiumType").Range("PremiumType")
  For Each cel In PremiumType.Columns(1).Cells
        MainTemp.Replace what:=cel.Value, replacement:=cel.Offset(0, 1).Value, LookAt:=xlWhole
    Next cel
End Sub
The problem is I have TypeA, TypeB in the cell and I want it to convert to the mapped values of A, B.

How do I modify it so that it will convert the cell containing : TypeA, TypeB rather than just TypeA?

Please help!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Change xlWhole to xlPart
You should also add the code in Orange or Excel will use whatever settings were used in the Find command the previous time it was used by code or by hand.
Rich (BB code):
Sub DataFormatPR()
    Dim PremiumType As Range
    Dim cel As Range
    
    Set PremiumType = Sheets("PremiumType").Range("PremiumType")
    For Each cel In PremiumType.Columns(1).Cells
        MainTemp.Replace What:=cel.Value, Replacement:=cel.Offset(0, 1).Value, LookAt:=xlPart, _
            MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    Next cel
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,652
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top