Indirect Not Working For Data Validation

mayoung

Active Member
Joined
Mar 26, 2014
Messages
257
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have been using this code for Data Validation for some time, but now when I try to use it, it throws a Run Time Error '1004' Application-Defined or Object-Defined Error. How can I change this to make it work again. I am using Office 365.

.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=INDIRECT(" & Cur_Cell & ")"

I am pretty sure this is the part of the code causing the issue:

Formula1:="=INDIRECT(" & Cur_Cell & ")"

Thanks In Advance For Any Help...
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Read this old thread https://www.mrexcel.com/forum/excel...-erroneous-list-formula-validation-vba-2.html

VBA is encountering the equivalent of "The source currently evaluates to an error" which you see when DV added manually
- Excel then helpfully offers option "Do you want to continue?" (which forces DV to be added)
- VBA does NOT have that option

The error is probably happening because Curr_Cell is empty, but woud also occur if its value is not valid
- the formula evaluates to an error and is rejected

Workaround
- test the value in Cur_Cell
- if that value is invalid (or empty), replace with a "Dummy" valid value (to force DV to be accepted)
- add DV
- if Curr_Cell = "Dummy" clear its contents
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,036
Members
449,205
Latest member
Eggy66

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