Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Arregla_sintaxis_IP()
- Dim cell As Range
- Dim re As New RegExp
- Dim DotsPositions(1 To 3) As Variant
- Dim tmpstr As String
- Dim cellstr As String
- With re
- re.Pattern = "\d{10,12}"
- re.IgnoreCase = True
- End With
- For Each cell In Selection
- tmpstr = ""
- cellstr = CStr(cell)
- ' En ese caso queremos meter una comillas (') delante y restaurar los puntos de los octetos
- If re.Test(cellstr) Then
- ' Convert to a string IP with dots
- For i = Len(cellstr) To 1 Step -1
- tmpstr = Mid(cellstr, i, 1) & tmpstr
- If ((((i - 1) Mod 3) = 0) And (i <> 1)) Then
- tmpstr = "." & tmpstr
- End If
- Next
- tmpstr = "'" & tmpstr
- cell.Value = tmpstr
- End If
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement