3
我有一個表如何複製多次重複單元格?
Name ID Salary Educ Exp Salary Educ Exp
Mike 1 100 5 12 200 12 23
Peter 2 200 6 12 300 3 32
Lily 3 150 3 13 200 5 2
...................
我需要把這個表格轉換爲
Name ID Salary Educ Exp
Mike 1 100 5 12
Peter 2 200 6 12
Lily 3 150 3 13
Mike 1 200 12 23
Peter 2 300 3 32
Lily 3 200 5 2
..................
我怎樣才能做到這一點使用VBA?
這裏是我試過到目前爲止
Sub test()
Dim rg1 As Range, rg2 As Range, rg3 As Range, shtDest As Worksheet
Dim lLoop As Long, lRowDest As Long
Set rg1 = Selection.Areas(1)
Set rg2 = Selection.Areas(2)
Set rg3 = Selection.Areas(3)
Set shtDest = Worksheets.Add
lRowDest = 1
For lLoop = 1 To rg1.Rows.Count
lRowDest = lRowDest + rg2.Rows.Count + rg3.Rows.Count
Next
End Sub
你目前的宏是什麼樣的? – admdrew
@admdrew,我已經包含了我的測試代碼。但它沒有任何作用 –
您的數據是否會像您在第一個示例中提供的那樣佈置,或者一個人是否有超過2個Salary/Educ/Exp條目?還是隻有一個呢? –