sconly
07-06-2011, 04:00 AM
I'm getting an 'application-defined or object-defined error' error when executing the code below.
it produces the error on the line in red.
For r = 4 To 5000
If ActiveSheet.Cells(r, 2).Value = "" Then
ActiveSheet.Range("B" & r).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=buildings"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ActiveSheet.Cells(r, 1).Formula = "=IF(B" & r & "<>"""",VLOOKUP(B" & r & ",Buildings!A:B,2,FALSE)"
Exit For
End If
Next r
The sheet is not locked/protected and the exact same code works on another workbook that I've created.
Can anyone help?
Thanks.
it produces the error on the line in red.
For r = 4 To 5000
If ActiveSheet.Cells(r, 2).Value = "" Then
ActiveSheet.Range("B" & r).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=buildings"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ActiveSheet.Cells(r, 1).Formula = "=IF(B" & r & "<>"""",VLOOKUP(B" & r & ",Buildings!A:B,2,FALSE)"
Exit For
End If
Next r
The sheet is not locked/protected and the exact same code works on another workbook that I've created.
Can anyone help?
Thanks.