Link to home
Start Free TrialLog in
Avatar of Kiwi-123
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"
Avatar of Norie
Norie

If what value, the username?
Avatar of Kiwi-123

ASKER

Hi Imnorie

the environ would equal the 0123 etc, but I'd want the code to use the nickname "Tom"
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Open in new window

Ooops.  Too late....didn't refresh...ignore me...