有用的幾行VB代碼
Sub 豎轉(zhuǎn)橫()
Dim a As Long, b As Long, c As Long, d As Long
a = 2: b = 3: c = 2: d = 3
Worksheets("sheet2").Cells(1, 1) = Worksheets("sheet1").Cells(1, 1)
Do Until IsEmpty(Cells(a, 1))
Worksheets("sheet2").Cells(c, 1) = Worksheets("sheet1").Cells(a, 1): Worksheets("sheet2").Cells(c, 2) = Worksheets("sheet1").Cells(a, 2)
Do Until Cells(a, 1) <> Cells(b, 1)
Worksheets("sheet2").Cells(c, d) = Worksheets("sheet1").Cells(b, 2)
a = a + 1
b = b + 1
d = d + 1
Loop
d = 3
a = a + 1
b = b + 1
c = c + 1
Loop
End Sub
Sub 刪除BCCH()
Dim a As Long, b As Long, c As Long
a = 2: b = 2: c = 3
Do Until IsEmpty(Cells(a, 1))
Do Until Worksheets("sheet1").Cells(a, 1) = Worksheets("sheet1").Cells(a, b)
b = b + 1
Loop
Worksheets("Sheet1").Cells(a, b).Delete shift:=xlShiftToLeft
b = 2
a = a + 1
Loop
End Sub
Sub 橫轉(zhuǎn)豎()
Dim a As Long, b As Long, c As Long
a = 2: b = 2: c = 2
Worksheets("sheet2").Cells(1, 1) = Worksheets("sheet1").Cells(1, 1)
Do Until IsEmpty(Worksheets("sheet1").Cells(a, 1))
Do Until IsEmpty(Worksheets("sheet1").Cells(a, b))
Worksheets("sheet2").Cells(c, 2) = Worksheets("sheet1").Cells(a, b)
Worksheets("sheet2").Cells(c, 1) = Worksheets("sheet1").Cells(a, 1)
c = c + 1
b = b + 1
Loop
b = 2
a = a + 1
Loop
End Sub