文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 使用VBA判断单元格各字符是否为中文、英文、数字、符号的复杂代码
侵权投诉

使用VBA判断单元格各字符是否为中文、英文、数字、符号的复杂代码

使用VBA判断单元格各字符是否为中文、英文、数字、符号的复杂代码

Function IsLike(strText As String, pattern As String) As Boolean

IsLike = strText Like pattern

End Function

Function IsChinese(strText As String) As Boolean

Dim i%, h$

h = Hex(Asc(strText))

If Asc(Left(h, 1)) >= 66 And Asc(Left(h, 1)) <= 70 Then

IsChinese = True

End If

End Function

Function StringType(strText As String, Optional outPutType As Integer = 1, Optional sumVar As Boolean = False) As Variant

Dim strtemp As String, blnArray(1 To 5) As String, strPreType As Integer

Dim intNum As Integer, startPos As Integer, intlen As Integer

Dim strArray As Variant, strCompare1 As String, strCompare2 As String, dblSum As Double If sumVar = True And Not (outPutType <> 2 Or outPutType <> 4) Then sumVar = False For i = 1 To Len(strText)

strtemp = Mid(strText, i, 1)

If i > 1 Then strCompare1 = WorksheetFunction.Asc(Mid(strText, i - 1, 3))

strCompare2 = WorksheetFunction.Asc(Mid(strText, i, 2))

If WorksheetFunction.Dbcs(strtemp) = strtemp Then

strtemp = WorksheetFunction.Asc(strtemp)

If IsLike(strtemp, "[0-9]") Or IsLike(strCompare1, "[0-9].[0-9]") Or IsLike(strCompare2, "-[0-9]") Then

If strPreType = 4 Then

blnArray(4) = Left(blnArray(4), Len(blnArray(4)) - 1) & intNum

Else

intNum = 1

blnArray(4) = blnArray(4) & "- " & i & "/" & intNum

End If

strPreType = 4

intNum = intNum + 1

ElseIf IsLike(strtemp, "[a-zA-Z]") Then

If strPreType = 5 Then

blnArray(5) = Left(blnArray(5), Len(blnArray(5)) - 1) & intNum

Else

intNum = 1

blnArray(5) = blnArray(5) & "- " & i & "/" & intNum

End If

strPreType = 5

intNum = intNum + 1

ElseIf IsChinese(strtemp) Then

If strPreType = 1 Then

blnArray(1) = Left(blnArray(1), Len(blnArray(1)) - 1) & intNum

第1页

你可能喜欢

  • VBA程序设计
  • Excel使用技巧大全(超
  • Excel教程
  • EXCEL随机
  • EXCEL函数
  • 随机数生成
  • 正则表达式
  • VBA教程

热门文档

相关文档

  • 单元格中出现错误的提示符号

    单元格中出现错误的提示符号_IT/计算机_专业资料。今日推荐 157份文档 ... 使用VBA判断单元格各字符... 3页 免费 运用提示符号批改作业 暂无评价 2页 ...

  • 使用VBA代码选择 单元格 区域

    代码选择单元格/区域 使用 VBA 代码选择单元格 区域使用 VBA 的常见任务是指定单元格或单元格区域,然后对该单元格或单元格区域进行一些 操作,如输入公式或更改格式...

  • 使用VBA代码确定激活选择单元格区域

    使用VBA代码确定激活选择单元格区域_IT/计算机_专业...以及工作表最后一行是否有可能被隐藏或不 显示零值... 使用VBA判断单元格各字符... 3页 免费 在VBA...

  • 第4章 VBA基础

    以下几个要素: VBA 代码由英文,中文,数字等字符...综上所述,在 VBA 代码中可使用各种常见的符号. 4... 它决定组成表达式的各个操作数是否参与计算以及什么...

  • VBA入门指南—如何看懂代码

    昨天我们在 VBA 代码编辑器里转了一圈,是不是有...容纳和组织代码的限定符号,一般和 End Sub 联用,...任何数字值或字符串值; Object:对象类型; 用户自...

  • 使用VBA代码确定、激活、选择单元格区域

    使用VBA代码确定、激活、选择单元格区域_IT/计算机_专业资料。使用VBA代码选定、激活单元格区域的多种方法,包括示例使用VBA代码确定、激活、选择单元格区域 如何选择...

  • Excel学习之使用VBA提取单元格字符-提取中间学校名-最...

    Excel VBA实例教程 #006... 1页 2下载券 在VBA代码中引用Excel工... 14... EXCEL用VBA实现单元格的... 2页 免费 Excel VBA如何引用单元格... 3页 1...

  • 提取字符串中汉字、英文与数字的函数

    3 人 jdi8 里面可能还含有不同的符号,如:“等。...组成的字符串中的英文与中文分别提取到其 它单元格...Function 最后,保存你的 Excel 文件,关闭 VBA 代码...

  • VBA技巧13 单元格中的公式

    VBA技巧13 单元格中的公式_计算机软件及应用_IT/...R1C1-样式符号表示的公式, 如下面的代 码所示。 ...错误类型, 来判断公式是否存在错误, 如下面的代码所...

  • 第9章 模块与VBA

    Access 将VBA程序代码保存为模块,通过事件触发模块 ...不能在变量名中使用空格、标 点符号等其它特殊字符...语句以计数值来判断循环是否结束之外,还可以用 “...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email