字符串分割,文末示例(文末代码3附有源码)
代码1 - 基础字符串
代码2 - 字符串拆分
代码3 - 字符串分割
Option ExplicitSub WorkbooksClear()Dim DataRange As RangeSet DataRange = Range("C2:E12")DataRange.Clear
End SubSub WorkbooksTest()Dim DataRange As RangeSet DataRange = Range("A2:A12")Dim DataRowCount As LongDataRowCount = DataRange.Rows.CountDim Index As IntegerFor Index = 1 To DataRowCountDim Item As RangeSet Item = DataRange.Cells(Index, 1)Dim Items() As StringItems = VBA.Split(Item, "-")Dim StringIndex As IntegerFor StringIndex = LBound(Items) To UBound(Items)Item.Offset(0, StringIndex + 2).Value = Items(StringIndex)Next StringIndexNext Index
End Sub
关注
笔者 - jxd