我正在尝试将行高从一张图纸1复制到图纸2。但以下代码不起作用。请注意,两张表上的表也位于不同的行号上。
Call Unhide
With Sheet1
Dim LastRowC23 As Integer
LastRowC23 = Application.WorksheetFunction.Match("CYCLE 1",
.Range("A:A"), 0) - 1
Dim LastRow As Integer
LastRow = .Cells(.Rows.count, "B").End(xlUp).Row
.Range("A3:BD3"), 0)
Dim C1StartCol As Integer
C1StartCol = Application.WorksheetFunction.Match("CYCLE 1",
.Range("A1:BD1"), 0)
Dim C2StartCol As Integer
C2StartCol = Application.WorksheetFunction.Match("CYCLE 2", .Range("A1:BD1"), 0)
Dim LastCol As Integer
LastCol = .Cells(3, .Columns.count).End(xlToLeft).Column
Sheet2.Range("A1:CZ200").Clear
.Range("A1", .Cells(3, C2StartCol - 1)).Copy
Sheet2.Range("A1").PasteSpecial xlPasteAllUsingSourceTheme
Sheet2.Range("A1").PasteSpecial xlPasteColumnWidths
.Range(.Cells(LastRowC23 + 1, 1), .Cells(LastRow - 1, C2StartCol - 1)).Copy
Sheet2.Range("A4").PasteSpecial xlPasteAllUsingSourceTheme
Sheet2.Range("A4").PasteSpecial xlPasteColumnWidths
Dim i As Integer
Dim count As Integer
count = 4
For i = LastRowC23 + 1 To LastRow
.Rows(count).RowHeight = Sheet2.Rows(i).RowHeight
count = count + 1
Next i
Sheet2.Outline.ShowLevels ColumnLevels:=1
End With
以下是特定于行高的零件。在这里,我将遍历表1部分中的每一行,并使表2的行高度等于表1的行高度。
Dim i As Integer
Dim count As Integer
count = 4
For i = LastRowC23 + 1 To LastRow
.Rows(count).RowHeight = Sheet2.Rows(i).RowHeight
count = count + 1
Next i