#### demodren

##### Board Regular
Hi, i am trying to incorporate the below formula into VBA but getting an error(application defined or object defined error).. Am i missing something here??

Any feedback is greatly appreciated!

Thanks so much

Dan

=LOOKUP(9^99,IF({1,0},0,LOOKUP(2,1/(P1=data!P\$1:P\$10001)/(E1=data!E\$1:E\$10001),data!K\$1:K\$10001)))

Code:
``````    Range("K1").Select
ActiveCell.FormulaR1C1 = "=LOOKUP(9^99,IF({1,0},0,LOOKUP(2,1/(P1=data!P\$1:P\$10001)/(E1=data!E\$1:E\$10001),data!K\$1:K\$10001)))"
Range("K1").Select``````

### Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

#### Jonmo1

##### MrExcel MVP
Change

FormulaR1C1 to Formula

Hope that helps.

#### xenou

##### MrExcel MVP
Use:
ActiveCell.Formula

Not ActiveCell.FormulaR1C1

(or convert the A1 style formula to an R1C1 style formula ... if you turn on the macro recorder, hit F2 in the cell with the formula, then hit enter, then stop and examine the recorded code you'll see an R1C1 formula).

ξ

#### demodren

##### Board Regular
thanks so much.. that worked! I am now trying to drag this all the way down to whatever is the last row is in the sheet but getting error "AutoFill method of Range class failed" am I missing something in the code?

Code:
``````Sub test()
'
Dim LastRow As Long
LastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

Range("K3").Select
ActiveCell.Formula = "=LOOKUP(9^99,IF({1,0},0,LOOKUP(2,1/(P3=data!P\$3:P\$10001)/(E3=data!E\$3:E\$10001),data!K\$3:K\$10001)))"
Range("K3").Select
Selection.AutoFill Destination:=Range("K3" & LastRow)
End Sub``````

#### Jonmo1

##### MrExcel MVP
Try

Code:
``Range("K3:K" & LastRow).Formula = "=LOOKUP(9^99,IF({1,0},0,LOOKUP(2,1/(P3=data!P\$3:P\$10001)/(E3=data!E\$3:E\$10001),data!K\$3:K\$10001)))"``

#### demodren

##### Board Regular
sweet! that did the trick

Replies
2
Views
99
Replies
0
Views
149
Replies
5
Views
136
Replies
2
Views
296
Replies
11
Views
810 Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

### Forum statistics

1,163,699
Messages
5,833,210
Members
430,197
Latest member
edeibold ### 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.

### Which adblocker are you using?    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

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