Am trying to write a simple program to create a validation list in select cells in a spreadsheet. (Office 2010, Windows 7)
This code works:
ActiveCell.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=indirect($C3)"
While the code above works, I do not want an absolute reference. The code below won’t work (Run Time Error 1004 – Application Defined or object defined error).
j = ActiveCell.Row
ActiveCell.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=indirect($C & j & )"
All I am changing is
from: Formula1:="=indirect($C3)" <-- the code that works
to: Formula1:="=indirect($C & j & )"
or: Formula1:="=indirect($C” & j & ”)"
Am I missing something in my syntax or is this a limitation with the Indirect function?
This code works:
ActiveCell.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=indirect($C3)"
While the code above works, I do not want an absolute reference. The code below won’t work (Run Time Error 1004 – Application Defined or object defined error).
j = ActiveCell.Row
ActiveCell.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=indirect($C & j & )"
All I am changing is
from: Formula1:="=indirect($C3)" <-- the code that works
to: Formula1:="=indirect($C & j & )"
or: Formula1:="=indirect($C” & j & ”)"
Am I missing something in my syntax or is this a limitation with the Indirect function?