2014-12-02 86 views
0

我有一個Excel表,但所有數據都在第1行上。我需要將第16列移動到下一行。所以我的數據應該在列1到列15中。我不擅長Excel,所以請耐心等待。將每第15列移動到新行

+1

數據如何進入Excel?以不同於當前表單的方式導入它可能會更容易。 – JJFord3 2014-12-02 15:12:28

+0

它以CSV文件的形式出現,通常我會用逗號進行分隔,並用逗號分隔它們,但它將它們全部放入第1行。 如果我從Excel複製第1行並將其粘貼到Word中,它不會正確格式化到表中。 – 2014-12-02 15:36:15

回答

1
Sub dividde_16() 

No_of_columns = Cells(1, Columns.Count).End(xlToLeft).Column 
No_of_rows = Int(No_of_columns/15) + 1 

For i = 1 To No_of_rows 
For j = 1 To 15 
    Cells(i + 1, j) = Cells(i * 15 + j) 
Next 
Next 
Range(Cells(1, 16), Cells(1, No_of_columns)) = "" 

End Sub 
0

你也許可以嘗試這樣的:

Sub Move_to_Columns() 
Dim lR As Long, R As Range 
lR = Range("A" & Rows.Count).End(xlUp).Row 
Set R = Range("A1", "A" & lR) 
Application.ScreenUpdating = False 
Application.Calculation = xlCalculationManual 
For Each C In R 
    If C.Row Mod 16 = 0 Then 
     C.Offset(-1, 1).Value = C.Value 
     C.ClearContents 
    End If 
Next C 
Application.Calculation = xlCalculationAutomatic 
End Sub 

但隨着列而不是行。

相關問題