lunedì 19 febbraio 2018

vba excel funzioni solo numeri e caratteri e solo telefoni

‘ Solo Numeri E caratteri

‘ esempio:

‘  

ddd,122/455     = ddd122455

 

 

 

Function SoloNumeriEcaratteri(S As String)

With CreateObject("vbscript.regexp")

  .Pattern = "[^0-9A-Za-z]"

  .IgnoreCase = True

  .Global = True

  SoloNumeriEcaratteri = .Replace(S, "")

End With

End Function

'

Function SoloTelefoni(S As String, tipo As String)

Dim telefono, uncarattere

With CreateObject("vbscript.regexp")

  .Pattern = "[^0-9]"

  .IgnoreCase = True

  .Global = True

  telefono = .Replace(S, "")

End With

'

SoloTelefoni = telefono

uncarattere = Left(telefono, 1)

If tipo = "fisso" Then

   If uncarattere = "0" Then

      SoloTelefoni = telefono

   Else

      SoloTelefoni = ""

   End If

End If

If tipo = "cellulare" Then

   If uncarattere = "3" Then

      SoloTelefoni = telefono

   Else

      SoloTelefoni = ""

   End If

End If

'

End Function

 

 

Nessun commento:

Posta un commento