Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1880|回复: 1

[已解决]谁可以帮我更改这个VBA

[复制链接]
发表于 2016-7-4 17:01 | 显示全部楼层 |阅读模式
本帖最后由 tt1668 于 2016-7-4 17:33 编辑

Function ch(x As Range) As String
    Dim A()
    Dim i As Integer
    A = Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I")
    For i = 1 To Len(x)
        ch = ch & A(Mid(x, i, 1))
    Next i
End Function

现在这如果我输入1234文字是ABCD,如果是有豆号的就不行了,我要怎样把豆号也用文字代替呢?比如说豆号的代替字是Z那么价钱1234.50就是(ABCDZEJ)
最佳答案
2016-7-4 17:18
  1. Function ch(x As Range) As String
  2.     Dim A()
  3.     Dim i As Integer
  4.     A = Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I")
  5.     For i = 1 To Len(x)
  6.         If IsNumeric(Mid(x, i, 1)) Then
  7.             ch = ch & A(Mid(x, i, 1))
  8.         Else
  9.             ch = ch & "Z"
  10.         End If
  11.     Next i
  12. End Function
复制代码
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-7-4 17:18 | 显示全部楼层    本楼为最佳答案   
  1. Function ch(x As Range) As String
  2.     Dim A()
  3.     Dim i As Integer
  4.     A = Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I")
  5.     For i = 1 To Len(x)
  6.         If IsNumeric(Mid(x, i, 1)) Then
  7.             ch = ch & A(Mid(x, i, 1))
  8.         Else
  9.             ch = ch & "Z"
  10.         End If
  11.     Next i
  12. End Function
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-3-29 15:16 , Processed in 0.328866 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表