Create a vba formula from cells

camle

Board Regular
Joined
Jan 10, 2013
Messages
216
Need a little assistance with a vba formula to get info from cells to create a formula like this
Code:
    Range("J1").Formula = "=IF(D1=""Mayberry R.F.D."",""Mayberry RFD""," & _
    "IF(D1=""Diners, Drive-ins and Dives"",""Diners Drive-Ins and Dives"",IF(D1=""Forever "",""Forever (2014)""," & _
    "IF(D1=""Food Factory (CA)"",""Food Factory CA"",IF(D1=""Castle (2009)"",""Castle 2009"",IF(D1=""Guy's Grocery Games"",""Guys Grocery Games"",D1))))))"

     Range("J1").Copy
    Range("J2:J" & LastRow).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False

I am constantly adding to the formula.
So, say column A would be what to look for, column B what to change to to.

Thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You're welcome. Thanks for the feedback.

You mixed D2 and D1 in the formaula?
=IFERROR(VLOOKUP(D2,Changes!A:B,2,0),D1)

I wound up with:
Code:
Range("J1:J" & LastRow).Formula = "=IFERROR(VLOOKUP(D1,Changes!A:B,2,0),D1)"
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

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