字符串分割,文末示例(文末代码3附有源码)

代码1 - 基础字符串

代码2 - 字符串拆分

代码3 - 字符串分割
cpp
Option Explicit
Sub WorkbooksClear()
Dim DataRange As Range
Set DataRange = Range("C2:E12")
DataRange.Clear
End Sub
Sub WorkbooksTest()
Dim DataRange As Range
Set DataRange = Range("A2:A12")
Dim DataRowCount As Long
DataRowCount = DataRange.Rows.Count
Dim Index As Integer
For Index = 1 To DataRowCount
Dim Item As Range
Set Item = DataRange.Cells(Index, 1)
Dim Items() As String
Items = VBA.Split(Item, "-")
Dim StringIndex As Integer
For StringIndex = LBound(Items) To UBound(Items)
Item.Offset(0, StringIndex + 2).Value = Items(StringIndex)
Next StringIndex
Next Index
End Sub
代码4 - 字符串连接

代码5 - 字符串替换

代码6 - 字符串比较、大小写转换

代码6 - 字符串查找

代码7 - "Like"正则

关注
笔者 - jxd