0
我正在嘗試編寫一個VBA腳本來格式化我存儲在Excel電子表格中的幾個thousdand電話號碼的列表。到目前爲止,我有這個,但是當我運行它時,它不會格式化電話號碼。如果單元格是空的,它確實添加了值NULL,但是沒有格式化數字,任何人看到我做錯了什麼?用於格式化電話號碼的VBA腳本
Sub CheckPhoneNumber()
Dim retNumber As String
Range("K3").Activate
Do Until ActiveCell.Row = 3746
If ActiveCell.Value = "" Then
ActiveCell.Value = "NULL"
Else
For i = 1 To Len(ActiveCell.Value)
If Asc(Mid(ActiveCell.Value, i, 1)) >= Asc("0") And Asc(Mid(ActiveCell.Value, i, 1)) <= Asc("9") Then
retNumber = retNumber + Mid(ActiveCell.Value, i, 1)
End If
Next
If Len(retNumber) > 10 Then
cleanPhoneNumber = Format(retNumber, "(+#) 000-000-0000")
Else
cleanPhoneNumber = Format(retNumber, "000-000-0000")
End If
End If
ActiveCell.Offset(1, 0).Activate
Loop
End Sub