I’m still new to programming in excel and I am having trouble making slight changes to my code.My code enables the user to select a cell and then use the up and down arrows to choose a defined value. Looking at the code below, I call the functions “UpOne” and “DownOne” in my worksheet and then I have my saved strings values in a module.
Worksheet Code
Private Sub Worksheet_Open()
Application.OnKey "{UP}", "UpOne"
Application.OnKey "{DOWN}", "DownOne"
End Sub
Module Code
Sub DownOne()
Select Case ActiveCell.Value
Case ""
ActiveCell.Value = "PASS"
Case "PASS"
ActiveCell.Value = "FAIL"
Case "FAIL"
ActiveCell.Value = "Unknown"
End Sub
Sub UpOne()
Select Case ActiveCell.Value
Case "Unknown"
ActiveCell.Value = "FAIL"
Case "FAIL"
ActiveCell.Value = "PASS"
Case "PASS"
ActiveCell.Value = ""
End Sub
My question is how would I make this code only work for all cells in one specific column? And how would I have different values when the user chooses a different column. So if user selects an empty cell in column “J”, he/she can navigates with the arrows keys through values such as “A”,”B”,”C” but when he/she selects an empty cell in Column “N”, he/she can navigate through a different set of values such as “E”, “F”, “G”, etc.
thank you for any help!
Rather than disabling/enabling code every time you selected a cell (plus you would need to cater for a multi-cell selection) it would be simpler for you to use Data Validation. You could set up lists that could apply to specific cells
Debra Dalgleish has an excellent discussion on Data Validation at Contextures