VB Code (Reference a cell to a IF/Vlookup)

rhjake23

New Member
Joined
Dec 20, 2017
Messages
35
Hello.

I am trying to do the following in VB.

Reference a cell to a IF & Vlookup statement.
Here is what I have currently.
Z is a variable that works...data can range from line 6 to line 1000.
----------------------------

Private Sub Reset_Pricing_Click()
(works) For Z = 6 To 1000
(works) If Worksheets("Test").Cells(Z, 4).Value = "" Then GoTo Done
(doesn't work) Worksheets("Test").Cells(Z, 13).Formula = "=IF(C6)=""CTLG"",VLOOKUP(B6),Sheet2!A:AG,33,FALSE),IF(C6)=""PGC"",VLOOKUP(D6),Sheet2!A:AG,33,FALSE),""""))"
(works) Worksheets("Test").Range("A" & Z, "K" & Z).Interior.ColorIndex = xlNone
(works) Next Z
Done:


End Sub
-------------------------------

Any ideas / suggestions would be greatly appreciated. Thank you.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You're formula is wrong.
Try typing it into a cell, then select that cell, start the macro recorder, press F2, stop the recorder, and you will see what the formula should. Albeit in R1C1 notation.
 
Upvote 0

Forum statistics

Threads
1,215,228
Messages
6,123,747
Members
449,118
Latest member
kingjet

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