Application Error 1004:

Glasgowsmile

Active Member
Joined
Apr 14, 2018
Messages
280
Office Version
  1. 365
Platform
  1. Windows
I've got this formula but keep getting a run time error (Application-defined or object-defined error). I've read about the error a few times but I don't understand what's causing the problem.

It's just a checkbox and I want to replace the formula used based on the status of the checkbox.

VBA Code:
Private Sub CheckBox1_Click()

If Range("$E$39") = "True" Then
    Range("F44").Formula = "=XLOOKUP($B44,Data!$M:$M,Data!R:R)"
Else
    Range("F44:F45").Formula = "=IFERROR(XLOOKUP($B44,Data!$M$3:$M$101,Data!R:R),"")"
End If
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
GIve this a try...essentially doubling the quotes in your second formula:

Private Sub CheckBox1_Click()

If Range("$E$39") = "True" Then
Range("F44").Formula = "=XLOOKUP($B44,Data!$M:$M,Data!R:R)"
Else
Range("F44:F45").Formula = "=IFERROR(XLOOKUP($B44,Data!$M$3:$M$101,Data!R:R),"""")"
End If
End Sub
 
Upvote 0
You need double quotes:
Rich (BB code):
Private Sub CheckBox1_Click()

If Range("$E$39") = "True" Then
    Range("F44").Formula = "=XLOOKUP($B44,Data!$M:$M,Data!R:R)"
Else
    Range("F44:F45").Formula = "=IFERROR(XLOOKUP($B44,Data!$M$3:$M$101,Data!R:R),"""")"
End If
End Sub
 
Upvote 0
Solution
Yeah, I discovered on my own it was the double quotes... I always make that mistake. Thanks!
 
Upvote 0
Glad we could help and thanks for the feedback (y)
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,973
Members
452,540
Latest member
haasro02

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