Kiwi-123
asked on
VB Command button
Private Sub CommandButton5_Click()
ActiveCell.Value = VBA.Environ("USERNAME")
ActiveCell.Offset(0, 1).Select
End Sub
Please can you help, I want to change the command button code so that if the value equals the following it will change to:-
"0123" change to "Tom"
"0124" change to "Sarah"
"0125" change to "Nick"
"0126" change to "Sophie"
ActiveCell.Value = VBA.Environ("USERNAME")
ActiveCell.Offset(0, 1).Select
End Sub
Please can you help, I want to change the command button code so that if the value equals the following it will change to:-
"0123" change to "Tom"
"0124" change to "Sarah"
"0125" change to "Nick"
"0126" change to "Sophie"
If what value, the username?
ASKER
Hi Imnorie
the environ would equal the 0123 etc, but I'd want the code to use the nickname "Tom"
the environ would equal the 0123 etc, but I'd want the code to use the nickname "Tom"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Something like this might work?
Select Case VBA.Environ("USERNAME")
Case "0123"
ActiveCell.Offset(0, 1).Value = "Tom"
Case "0124"
ActiveCell.Offset(0, 1).Value = "Sarah"
Case "0125"
ActiveCell.Offset(0, 1).Value = "Nick"
Case "0126"
ActiveCell.Offset(0, 1).Value = "Sophie"
End Select
Ooops. Too late....didn't refresh...ignore me...