Hello All
Hope you are all keeping well.
My knowledge with VBA is very limited and i need help reducing code.
This is what i have sover:
[VBA]
Sub split() '// This sub takes the first 3 char from each cell in range and offsets that value to the next column
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("A1:A8")
For Each cel In SrchRng
cel.Offset(0, 1).Value = Left(cel.Value, 3)
Next cel
End Sub
Sub AddName() ' // This sub then checks the cells in the range and allocates a Name to the next column
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("B1:B8")
For Each cel In SrchRng
If InStr(1, cel.Value, "BEE") > 0 Then
cel.Offset(0, 1).Value = "Dr Beeton"
ElseIf InStr(1, cel.Value, "BET") > 0 Then
cel.Offset(0, 1).Value = "Dr Bettings"
Else
cel.Offset(0, 1).Value = "Error"
End If
Next cel
End Sub[/VBA]
Where i need help is, i have over 80 abbreviation(BEE,BET) than needs to be assigned to specific Names. I can just ElseIf my way though all of the abbreviations and it should work, however, i feel there should be a better way of getting though all those without having 80 ElseIf statements.
This is the results after running the Subs with static data being in Range("A1:A8")
[ATTACH=JSON]{"alt":"Click image for larger version Name:\tSheet1.JPG Views:\t1 Size:\t21.3 KB ID:\t1207680","data-align":"none","data-attachmentid":"1207680","data-size":"full","title":"Sheet1.JPG"}[/ATTACH]
I would appreciate any help regarding this...thx yall