On my sheet, columns FK:FX of the current row have data. I have a macro that creates a Data Validation list in a specific cell of the currently selected row. Unfortunately, it does not work with the FK:FZ range. If I change it to just FK it works fine. Is it possible to use a range of cells to populate the data validation list?
Here's my code:
Here's my code:
VBA Code:
Sub ModelSelect()
Cells(ActiveCell.Row, "FZ").Activate
ActiveSheet.Unprotect
aRange = Cells(ActiveCell.Row, "FK:FX")
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=aRange
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
End Sub