I am trying to set the data validation for a range of cells using VBA. I get a run-time error 1004 (so helpful) \"Application defined or object defined error\" with this cod
I have referenced named location using the INDIRECT function and everything run perfect. Users however reported some regular, seemingly random errors and from log file I saw that this Validation.add is causing the problem. The thing is, that the Excel tool is running in background while different Excel file operated by user may have focus when this operation is executed.
Didn't test the following Code. Hope it helps.
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= xlBetween, Formula1:="=INDIRECT(""[" & ThisWorkbook.Name & "]" & sht_sfDocumentation.Name & "!" & gstrRANGE_NamedTableRange & """)"