首页 > 解决方案 > 将字符串拆分为多个单元格

问题描述

我有个问题。

我有这个:

("boufous;othman;212544;casa")

我想将此单元格拆分为多个单元格,例如:

cell[1]=boufous cell[2]=othman cell[3]=212544 cell[4]=casa

For Each olMailItem In olItems
   //Code here

    i = i + 1

Next olMailItem

标签: excelvbasplit

解决方案


假设 olMailItem 作为字符串,下面是代码

Dim str1, str2
olMailItem = "boufous;othman;212544;casa"
str1 = Split(olMailItem, ";")
str2 = UBound(str1)
For i = 0 To str2
    Debug.Print str1(i)
Next i

推荐阅读