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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try this...

Code:
Range("J1:J" & LastRow).Formula = "=IFERROR(VLOOKUP(D1,A:B,2,0),"""")"
 
Last edited:
Upvote 0
You're welcome. Thanks for the feedback.

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

Forum statistics

Threads
1,213,494
Messages
6,113,986
Members
448,538
Latest member
alex78

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