Hello,
I'm stumped. I'm trying to add validation to a particular column in a table and am getting a runtime error 1004 Application-defined or object-defined error in the '.ADD Type:= ...' line.
Any help is greatly appreciated. Code follows.
Thanks in advance
I'm stumped. I'm trying to add validation to a particular column in a table and am getting a runtime error 1004 Application-defined or object-defined error in the '.ADD Type:= ...' line.
Any help is greatly appreciated. Code follows.
Thanks in advance
VBA Code:
Sub ABS_Validation()
Dim LR As Long
TargetWS = "DB_ABS"
TargetColumn = "ABS_Data[[#Headers],[N° de Orden]]"
FR = Sheets(TargetWS).Range(TargetColumn).Row + 1
LR = Sheets(TargetWS).Range(TargetColumn).End(xlDown).Row
ValidationRange = "U" & FR & ":U" & LR
Debug.Print ValidationRange
Set ws = ActiveWorkbook.Sheets(TargetWS)
Set ApprovalsValidation = ws.Range(ValidationRange)
ValidationList = Chr(160) & ",Aprobado,Rechazado"
With ApprovalsValidation.Validation
.Delete 'delete previous validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:=ValidationList
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = False
.ShowError = True
End With
End Sub