condicionar en VBA

Osasa54

New Member
Joined
Sep 10, 2002
Messages
31
Hola!! Se puede condicionar en VBA a un valor numérico o alfabético?
ejemplo

If Mid(matricula, 1, 1) <= 9 Then ...

me gustaría que en vez del 9 pudiera poner = "valor numérico", además de poder realizar la otra posibilidad, la de que en vez de un número sea una letra.

Gracias
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Esto ?

Code:
If IsNumeric(Left(matricula, 1)) Then

End If

otra opción es revisar el código ASCII del caracter, por ejemplo, las letras A-Z están en el rango 65 - 90, así que se podría hacer:

Code:
If Asc(UCase$(Left$(matricula, 1))) >= 65 And Asc(UCase$(Left$(matricula, 1))) <= 90 Then

End If

para revisar que sean textos...

otra opción es utilizar la función Like, así:

Code:
If UCase$(Left$(matricula, 1)) Like "[A-Z]" Then

End If
 
Upvote 0

Forum statistics

Threads
1,216,146
Messages
6,129,142
Members
449,488
Latest member
qh017

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