2013-12-12 34 views

回答

1

試試這個

Sub a() 
DataRow = 1 
DataCol = 1 
OutputRow = 1 
OutputCol = 4 

Application.ScreenUpdating = False 
OutputCol = OutputCol - 1 
While Cells(DataRow, DataCol).Value <> 0 
    Cells(DataRow, DataCol).Select 
    ThisValue = Cells(DataRow, DataCol).Value 
    If ThisValue <> PrevValue Then 
     OutputCol = OutputCol + 1 
     MyRow = OutputRow 
     Cells(MyRow, OutputCol).Value = Cells(DataRow, DataCol).Value 
     MyRow = OutputRow + 1 
    End If 
    Cells(MyRow, OutputCol).Value = Cells(DataRow, DataCol + 1).Value 
    PrevValue = ThisValue 
    DataRow = DataRow + 1 
    MyRow = MyRow + 1 
Wend 
Application.ScreenUpdating = True 
End Sub 
相關問題