使用VBA从字符串中提取数据

时间:2014-02-19 11:07:37

标签: excel-vba vba excel

以下是声明

Performance;#Recruiting;#Culture and values;#Community Involvement &
Volunteerism;/Talent Development;#Workplace

我希望在#符号粘贴到新单元格后出现每个值?我该怎么做?

2 个答案:

答案 0 :(得分:0)

我已经有一段时间没有使用过VBA了,但这应该至少让你开始:

Private Sub ProcessStr()
    Dim strTest As String
    Dim strArray() As String
    Dim i As Integer

    strTest = "YOUR STRING"
    strArray = Split(strTest, ";")

    For i = LBound(strArray) To UBound(strArray)
        // REMOVE # SIGN HERE ?
        // DO SOMETHING WITH THE VALUES
        // strArray(i) - CONTAINS EACH VALUE
        // PLACE IN INDIVIDUAL CELLS
    Next
End Sub

希望这有帮助!

答案 1 :(得分:0)

dim arrString() as string
dim strInput as string
dim i as integer

strInput = "Performance;#Recruiting;#Culture and values;#Community Involvement &
Volunteerism;/Talent Development;#Workplace"
arrStrings = strings.split(strInput, ";#")
for i = 1 to ubound(arrstrings)
    cells(i, 1) = arrstrings(i)
next i
相关问题