excel VBA替换字符
3个回答
展开全部
Sub changeNum()
Dim myInp As String, myRng As Range, c As Range, i As Integer, myStr As String
myInp = InputBox("请输入单元格区域:")
myInp = Replace(Replace(myInp, "(", ""), ")", "")
On Error GoTo check
Set myRng = Range(myInp)
On Error GoTo 0
For Each c In myRng.Cells
myStr = ""
For i = 1 To Len(c)
myStr = myStr & Chr(Asc(Mid(c.Value, i, 1)) + 17)
Next i
c = myStr
Next c
Exit Sub
check:
MsgBox "输入区域非法"
End Sub
展开全部
Sub 替换()
Dim a, b, c As Integer
c = 7 '第7行
For a = 1 To 4 '共计4行数据
For b = 3 To 5 '每行3个数据
If ActiveSheet.Cells(c, b) = "0123456789" Then
ActiveSheet.Cells(c, b) = "ABCDEFGHIJ" '替换数据
End If
Next b
c = c + 1 '+1换行
Next a
End Sub
我好仰慕楼下大神的代码,我等无限膜拜中。
Dim a, b, c As Integer
c = 7 '第7行
For a = 1 To 4 '共计4行数据
For b = 3 To 5 '每行3个数据
If ActiveSheet.Cells(c, b) = "0123456789" Then
ActiveSheet.Cells(c, b) = "ABCDEFGHIJ" '替换数据
End If
Next b
c = c + 1 '+1换行
Next a
End Sub
我好仰慕楼下大神的代码,我等无限膜拜中。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用replace吧
追问
用了不行,不知代码哪里错
给个完整的代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询