VBA if Cell is equal to this put a selected value in another empty cell

CLCoop

Board Regular
Joined
May 30, 2018
Messages
56
Working within a pivot table and have added additional columns this way people can see what they spent and projected in the past and input for the future. However I have slicers so you select your Branch which auto populates in Column L, based on the auto populated Column L (Branch) want J (Division) to look at L and put in the assigned Division on what is in L. I tried to cheat and just do a formula to copy what was in L to put it in J then change it using the code below

Keep in mind this is a pivot table that will grow or shrink based on the branches selected.

For example Right now Column L shows RD1SL13310 - OSB so does Column J because I used the formula =L20 but I need to have OSB change to DFM in column J. This is the code I tried:

Columns("J:J").Select
Selection.Replace What:="RD1SL13310 - OSB", Replacement:="RD1SL13000 - DFM", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

That didn't work so I then tried:
Selection.Replace What:="RD1SL13000 - DFM", Replacement:="MRD1SL13310 - OSB", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False


Is there a faster more effective way to do this?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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