Hi
I have some code which is in the objects are of various workbooks. This code effectively changes fractional odds to decimal, so 7/2 becomes 4.50 and so on.
Here is the code
That works really well, but I now need to change various text possibilities as they happen. So there will be things like pu, F, ro, ur and so on and each has a corresponding number. So I was after something similar to the above where it is input directly into the worksheet's object area, so if someone types pu in column AA, it automatically changes to 509.
Here is a list of the codes and the corresponding number. The few capital letters are deliberate
500 NR
501 ur
502 co
503 r
504 ro
505 bd
506 su
507 L
508 W
509 pu
512 F
514 D
515 hr
516 rr
517 dnf
I need the code to be changed into the number once it is typed, just as the fractional odds change as soon as you move cell. I hope it is possible
Thanks in advance
I have some code which is in the objects are of various workbooks. This code effectively changes fractional odds to decimal, so 7/2 becomes 4.50 and so on.
Here is the code
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo err_handler
Application.EnableEvents = False
If Target.CountLarge > 1 Then GoTo exit_handler
If Target = Empty Then GoTo exit_handler
If Not Intersect(Target, Columns("Y")) Is Nothing Then
With Target
.NumberFormat = "@"
.Value = CDbl(Evaluate(.Value & "+1"))
If (.Value - Fix(.Value)) = 0 Then
.NumberFormat = "0"
Else
.NumberFormat = "0.00"
End If
End With
End If
exit_handler:
Application.EnableEvents = True
Exit Sub
err_handler:
MsgBox Err.Number & ": " & Err.Description
Resume exit_handler
End Sub
That works really well, but I now need to change various text possibilities as they happen. So there will be things like pu, F, ro, ur and so on and each has a corresponding number. So I was after something similar to the above where it is input directly into the worksheet's object area, so if someone types pu in column AA, it automatically changes to 509.
Here is a list of the codes and the corresponding number. The few capital letters are deliberate
500 NR
501 ur
502 co
503 r
504 ro
505 bd
506 su
507 L
508 W
509 pu
512 F
514 D
515 hr
516 rr
517 dnf
I need the code to be changed into the number once it is typed, just as the fractional odds change as soon as you move cell. I hope it is possible
Thanks in advance