我在处理电话号码格式时遇到问题,国家/地区代码与0重复, 示例 - +44 440 800 093 3633& 0031651497715(44 +之后+44和44没有+和零)和& (0031成为+31 31) 有没有办法为此编写宏(如果有国家代码那么 下一步或者添加国家代码,但国家代码后不应该有重复和零)。 我非常感谢你的帮助。
我的代码如下 -
Sub twodigits()
Dim Remove(), x As Integer, nROWS As Integer
On Error Resume Next
nROWS = Selection.Rows.Count
ThisWorkbook.ActiveSheet.Activate
ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column + 1).Select
Remove() = Array("~", "`", "!", "@", "#", "$", "%", "^", "&", "(", ")", "-",
"_", "=", "{", "}", "[", "]", "\", "|", ";", ":", "'", ",", "<", ">", "/",
".", " ")
For x = 1 To nROWS
ActiveCell.Value = "'" & ActiveCell.Offset(0, -1).Value
For Each i In Remove()
ActiveCell.Replace What:=i, Replacement:=" ", MatchCase:=True
Next i
If Left(ActiveCell.Value, 1) = "+" Then ActiveCell.Replace What:=Left(ActiveCell.Value, 3), Replacement:=" ", MatchCase:=True
If Left(ActiveCell.Value, 1) = "0" Then ActiveCell.Replace What:=Left(ActiveCell.Value, 1), Replacement:="", MatchCase:=True
'If Left(ActiveCell.Value, 1) = "0" Then ActiveCell.Replace What:=Left(ActiveCell.Value, 1), Replacement:="", MatchCase:=True
ActiveCell.Value = "'" & ActiveCell.Offset(0, -2).Value & ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Next x
End Sub