excel怎么让我输入的数字变成字母 - 爱问答

(爱问答)

excel怎么让我输入的数字变成字母

excel怎么让我输入的数字变成字母,例如输入1就显示a。2就是b,3就是c,12就是ab,123就是abc

(一)假设在A1输入,自动变成所需字符

excel怎么让我输入的数字变成字母

excel怎么让我输入的数字变成字母

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address(0, 0) <> "A1" Then Exit Sub

Application.EnableEvents = False

On Error Resume Next

For i = 1 To Len(Target)

On Error Resume Next

n = CInt(Mid(Target, i, 1))

    If Err.Number = 0 Then

        If n > 0 And n < 10 Then

            s = s & Chr(96 + n)

        Else

            s = s & Mid(Target, i, 1)

        End If

    Else

        s = s & Mid(Target, i, 1)

    End If

Resume

Next i

Target = s

Application.EnableEvents = True

End Sub

(二)假设在A列输入,自动变成所需字符

将上面

If Target.Address(0, 0) <> "A1" Then Exit Sub

一句改为

If Target.Column <> 1 Then Exit Sub

(三)假设在整个Sheet1工作表中输入,自动变成所需字符

就去掉

If Target.Address(0, 0) <> "A1" Then Exit Sub

一句。

(四)假设在整个工作簿输入,自动变成所需字符

excel怎么让我输入的数字变成字母

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Application.EnableEvents = False

On Error Resume Next

For i = 1 To Len(Target)

On Error Resume Next

n = CInt(Mid(Target, i, 1))

    If Err.Number = 0 Then

        If n > 0 And n < 10 Then

            s = s & Chr(96 + n)

        Else

            s = s & Mid(Target, i, 1)

        End If

    Else

        s = s & Mid(Target, i, 1)

    End If

Resume

Next i

Target = s

Application.EnableEvents = True

 

End Sub


相关标签:excel

下一篇:win7升win10的系统文件可以用硬盘而不用U盘升级吗?

上一篇:机械师笔记本F117-VB1用3D,CAD会不会卡?

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?