Shippwreck
Programmer
Hi All,
I'll get to the point. I am using lists in a spreadsheet to force users to select only valid entries for cells. I have one column of cells where the users enter a code. I would like the cell to columns over to have a list that is dependant on the first cell.
I have created a macro that when it runs it looks at the active cell and says if the cell equals a certain value then select the cell two columns across and use these .... values as the list for that cell.
That works great, except i would like to make that macro run as soon as the user presses enter to move to the next cell (or clicks somewhere else in the sheet)
But as you may of guessed that is what i'm having problems doing, i have tried to make it a function but without much success, the code for the macro is below:
Sub Calc()
If ActiveCell = "101" Then
ActiveCell.Next.Select
ActiveCell.Next.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="pigs, horses"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
End If
End Sub
As you might be able to tell i recorded and then edited it.
Anyway any help would be much appreciated,
Thank you in advance
I'll get to the point. I am using lists in a spreadsheet to force users to select only valid entries for cells. I have one column of cells where the users enter a code. I would like the cell to columns over to have a list that is dependant on the first cell.
I have created a macro that when it runs it looks at the active cell and says if the cell equals a certain value then select the cell two columns across and use these .... values as the list for that cell.
That works great, except i would like to make that macro run as soon as the user presses enter to move to the next cell (or clicks somewhere else in the sheet)
But as you may of guessed that is what i'm having problems doing, i have tried to make it a function but without much success, the code for the macro is below:
Sub Calc()
If ActiveCell = "101" Then
ActiveCell.Next.Select
ActiveCell.Next.Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="pigs, horses"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
End If
End Sub
As you might be able to tell i recorded and then edited it.
Anyway any help would be much appreciated,
Thank you in advance