Thebatfink
Active Member
- Joined
- Apr 8, 2007
- Messages
- 410
Hi,
I need to add data validation to a range of cells in many workbooks and I'm trying to perform this using vb so they dont have to manually open up each one and do it one at a time. I'm struggling with the syntax to make this happen. Using the macro record I came up with this but it doesn't like it for some reason..
Nor does it like..
Can anyone tell me the correct syntax to use. Thanks.
I need to add data validation to a range of cells in many workbooks and I'm trying to perform this using vb so they dont have to manually open up each one and do it one at a time. I'm struggling with the syntax to make this happen. Using the macro record I came up with this but it doesn't like it for some reason..
Code:
ws2.Range("a7:a40").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$R$1:$R$5"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Nor does it like..
Code:
ws.Range("a7:a40").Validation.Formula1 = "=$R$1:$R$5"
Can anyone tell me the correct syntax to use. Thanks.