VBA: Accounting for Non-Numeric #s, How if not ISNUMERIC?

Sphinx404

Board Regular
Joined
May 2, 2015
Messages
186
Office Version
  1. 365
Platform
  1. Windows
I am trying to account for non-numeric values at the end of my string. I input MSP just to test if the code would work with my data set. THE PROBLEM: "MSP" can be any combination of letters and I need to account for all variations. The part of the code in PURPLE has no effect on the data, which renders my CASE useless.

Anyone have any idea how I can account for the random letters at the end of my string?

Code:
Select Case True    Case Left(mycell.Value, 3) = "006"
        If IsNumeric(Right(mycell.Value, 8)) Then
            mycell.Offset(, 16).Value = Right(mycell.Value, 8)
        Else
            mycell.Offset(, 16).Value = Mid(mycell.Value, 4, 8)
        End If
[COLOR=#4b0082]    Case Right(mycell.Value, 3) = "[/COLOR][COLOR=#0000ff][B]MSP[/B][/COLOR][COLOR=#4b0082]"[/COLOR]
[COLOR=#4b0082]        If IsNumeric(Left(mycell.Value, 3)) Then[/COLOR]
[COLOR=#4b0082]            mycell.Offset(, 16).Value = Mid(mycell.Value, 4, 8)[/COLOR]
[COLOR=#4b0082]        Else[/COLOR]
[COLOR=#4b0082]            mycell.Offset(, 16).Value = "Research"[/COLOR]
[COLOR=#4b0082]        End If[/COLOR]
    Case Left(mycell.Value, 2) = "06"
        If IsNumeric(Right(mycell.Value, 8)) Then
            mycell.Offset(, 16).Value = Right(mycell.Value, 8)
        End If
    Case Len(mycell.Value) = 0
            mycell.Offset(, 16).Value = "Research"
End Select

081-8185-4765Research
695-13834170 ATL-21408790Research
00695446750MSP95446750
00695466766ATL95466766
006DTWDTW - needs to say "research"
00695466044MSP95466044
ATL00695479042need last 8 digits
06DTW9554738495547384
006ATAT - needs to say "research"
081-8185-4776Research
081-8185-4791Research
006MSP34504901-39:05167MSP34504 - needs to say "research"

<tbody>
</tbody>

Excel MVPs? Macro Kings? Giants of Excel? I need you. THANKS!
 
Last edited:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi

For any combination of 3 letters at the end of the string try:

Code:
       Case UCase(mycell.Value) Like "*[A-Z][A-Z][A-Z]"
 
Upvote 0

Forum statistics

Threads
1,215,796
Messages
6,126,957
Members
449,350
Latest member
Sylvine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top