Sub RearangeWorkSheet2()
Const IDColumn = 1
Dim arrData()
Dim i As Long, j As Long, RecordID As Long, lastRow As Long, x As Long, y As Long
lastRow = Range("B" & Rows.Count).End(xlUp).row
ReDim arrData(3, 0)
For x = 2 To lastRow
If Cells(x, 1) <> "" Then
RecordID = i
ReDim Preserve arrData(3, i)
arrData(0, RecordID) = Cells(x, 1)
i = i + 1
End If
If IsNumeric(Left(Cells(x, 2), 3)) Then
y = 1
ElseIf InStr(Cells(x, 2), "@") Then
y = 2
Else
y = 3
End If
For j = RecordID To UBound(arrData, 2)
If IsEmpty(arrData(y, j)) Or j = UBound(arrData, 2) Then Exit For
Next
If Not IsEmpty(arrData(y, j)) Then
ReDim Preserve arrData(3, i)
i = i + 1
j = j + 1
End If
arrData(y, j) = Cells(x, 2)
Next
Worksheets("Sheet1").Range("D2").Resize(UBound(arrData, 2) + 1, 4).Value = WorksheetFunction.Transpose(arrData)
End Sub
我們很難幫助,如果我們看不到代碼。記住在你的問題中編輯它?至於檢查@符號,你可以做一些像'InStr(ADDRESS_TO_CHECK,「@」)'(Instr docs:https://msdn.microsoft.com/en-us/library/8460tsh1(v=vs.90 ).aspx) – Mikegrann
我會使用像Instr(1,ADDRESS_TO_CHECK,「www」)這樣的網站,因爲你的電話號碼也會通過@檢查。你到目前爲止是否嘗試過任何代碼? –
請發佈您到目前爲止的代碼。此外,它看起來像你的數據[電話號碼],[電子郵件],[網站]。它總是**會變成這樣嗎?或者你可以混合使用,如[電話號碼],[網站],[電子郵件],[網站]? – BruceWayne