|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
如果是由510621666变成>>>> 520612666
- Sub ReplaceNumbers()
- Dim cell As Range
- Dim ws As Worksheet
- Dim cellValue As String
- Dim newValue As String
-
- For Each ws In ThisWorkbook.Worksheets
- For Each cell In ws.UsedRange
- cellValue = cell.Value
- newValue = ""
- For i = 1 To Len(cellValue)
- If Mid(cellValue, i, 1) = "1" Then
- newValue = newValue & "2"
- ElseIf Mid(cellValue, i, 1) = "2" Then
- newValue = newValue & "1"
- Else
- newValue = newValue & Mid(cellValue, i, 1)
- End If
- Next i
- cell.Value = newValue
- Next cell
- Next ws
- End Sub
复制代码
|
|