Hi Members,
I'm trying to pull out a validation list based on a if statement, with the following code
but I'm getting a type mismatch error driven by the "sList" so I tried with
due to the named range, but then I got an error on the following line (object variable not set - error 91)
as I'm still learning macros in excel, I don't know what I'm doing wrong, so any help will be more than welcome.
I'm trying to pull out a validation list based on a if statement, with the following code
Code:
Sub ValJBA()
Dim i As Long
Dim sList As String
Dim dv As Validation
Dim wks As Worksheet
Set wks = Sheets("JBA - SpaEn")
If wks.Range("C23") = "Intercompany" Then
sList = Range("INT")
ElseIf wks.Range("C23") = "Operative" Then
sList = Range("CAR")
Else
sList = Range("CTE")
End If
Set dv = Range("G23").Validation
dv.Delete
dv.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:=sList
End Sub
but I'm getting a type mismatch error driven by the "sList" so I tried with
Code:
Dim sList As Range
due to the named range, but then I got an error on the following line (object variable not set - error 91)
Code:
sList = Range ("INT")
as I'm still learning macros in excel, I don't know what I'm doing wrong, so any help will be more than welcome.