這裏有一種方法可以解決這個問題;它做出了一些假設,如果它們證明是錯誤的,你可能不得不解決。
Dim n As String
Dim v As String
Dim row As Long
Dim col As Integer
Dim c As Range
Dim destRow As Long
Dim destCol As Integer
'Assume your data is in column A, starting in row 1
row = 1
col = 1
'and that you want to drop it into columns C and D starting in row 1
destRow = 1
destCol = 3
Do
Set c = ActiveSheet.Cells(row, col)
If Left(c.Value, 4) = "Name" Then
n = c.Value
ElseIf n <> "" Then
Cells(destRow, destCol).Value = c.Value
Cells(destRow, destCol + 1).Value = n
destRow = destRow + 1
End If
row = row + 1
Loop Until ActiveSheet.Cells(row, col).Value = ""
1 2 3單元中有什麼樣的數據?它總是相同的類型?也就是說,非名稱數據會一直是日期還是數字等? – Michael 2010-06-23 13:38:34
全部都是文字 – LIX 2010-06-23 13:41:23
您是否有辦法區分Name1,Name2等與其餘字符串? – technomalogical 2010-06-24 13:24:12