How can I make it so that if a user in enters t or T in a specific cell the cell automatically shows "TRUE" and if they enter f or F the cell shows "FALSE"
I need this condition on cells in range G11:G24
thank you for your time and help.
How can I make it so that if a user in enters t or T in a specific cell the cell automatically shows "TRUE" and if they enter f or F the cell shows "FALSE"
I need this condition on cells in range G11:G24
thank you for your time and help.
Hi
It's easier if you restrict the user input to True and False with a dropdown using a list in Data>Validation.
If for some reason you really want to have the user input t or T and automatically change the value of the cell to True, you have to use vba. Use the worksheet Change Event.
HTH
lecxe
I would like to use the change event, but I don't know how write it.
I have this change event I have been using but don't know how to edit it to fit my needs.
Would you know how to change it?
![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub On Error Resume Next If Not Intersect(Target, Range("G11:G50")) Is Nothing Then Application.EnableEvents = False Target = UCase(Target) Application.EnableEvents = True End If On Error GoTo 0 End Sub
Maybe
VBA Noob![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub On Error Resume Next If Not Intersect(Target, Range("G11:G50")) Is Nothing Then Application.EnableEvents = False Select Case UCase(Target.Value) Case "F" Target.Value = "True" Case "T" Target.Value = "False" Case Else Target.Value = UCase(Target.Value) End Select Application.EnableEvents = True End If On Error GoTo 0 End Sub
_________________________________________
![]()
![]()
Credo Elvem ipsum etian vivere
_________________________________________
A message for cross posters
Please remember to wrap code.
Forum Rules
Please add to your signature if you found this link helpful. Excel links !!!
Hi again
You can complement VBA Noob's code with Data Validation in the worksheet to ensure that the user is only allowed to enter the letters f and t.
Or just tweak it slightly
VBA Noob![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub On Error Resume Next If Not Intersect(Target, Range("G11:G50")) Is Nothing Then Application.EnableEvents = False Select Case UCase(Target.Value) Case "F" Target.Value = "True" Case "T" Target.Value = "False" Case Else Application.Undo End Select Application.EnableEvents = True End If On Error GoTo 0 End Sub
code works, but I am unable to delete the cell contents. How do I fix this??
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks