道歉,如果這看起來像是重複的,但是我正在尋找一個可能是常見問題的特定解決方案。從一系列單元格中添加列
我有下面的代碼從一個單元格區域添加行:
Sub Insert_Matrix_Rows()
Dim Lr As Integer, Fr As Integer
Fr = Columns("B").Find(What:="User R", After:=Range("B9")).Row 'Searching row of "User R" header
Lr = Range("B" & Fr).End(xlDown).Row 'Searching last row in Risk table
Rows(Lr + 1).Insert Shift:=xlDown 'Inserting new row
'Cells(Lr + 1, "B") = Cells(Lr, "B") + 1 'Adding a sequential number
Rows(Lr).Copy 'Copying format of last row
Rows(Lr + 1).PasteSpecial Paste:=xlPasteFormats 'Pasting format to new row
Application.CutCopyMode = False 'Deactivating copy mode
Cells(Lr + 1, "C").Select
End Sub
我將其指定爲宏和它的作品複製第9行,並粘貼低於行。本質上,我想複製此過程的列。因此,生成列時可能包含上述代碼生成的任何行,反之亦然。
我試圖做翻譯的代碼爲列的工作,但我遇到錯誤(類型不匹配):
Sub Insert_Matrix_Columns()
Dim Lc As Integer, Fc As Integer
Fc = Columns("D").Find(What:="User C", After:=Range("E6")).Column 'Searching row of "User C" header
Lc = Range("E" & Fr).End(xlRight).Column 'Searching last row in Risk table
Columns(Lc + 1).Insert Shift:=xlRight 'Inserting new row
'Cells(Lr + 1, "B") = Cells(Lr, "B") + 1 'Adding a sequential number
Columns(Lc).Copy 'Copying format of last row
Columns(Lc + 1).PasteSpecial Paste:=xlPasteFormats 'Pasting format to new row
Application.CutCopyMode = False 'Deactivating copy mode
Cells(Lc + 1, "E").Select
End Sub
在哪一行出現錯誤? – avb
錯誤發生在:Sub Insert_Matrix_Columns(),該行包含「Fc - ...」 – Idrawthings
o認爲您的評論中缺少somehing – avb