У меня есть код, который копирует данные с нескольких листов на мастер-лист. Все данные вставляются в 1-й строке. Мне было интересно, что если есть способ, где 1-я строка содержит предопределенный заголовок, и все данные должны быть вставлены во второй столбец под заголовком.
Set CopyRng1 = sh.Range("B3")
Set CopyRng2 = sh.Range("C3")
Set CopyRng3 = sh.Range("D3")
Set CopyRng4 = sh.Range("G3")
Set CopyRng5 = sh.Range("C5")
Set CopyRng6 = sh.Range("A8:j25")
Set CopyRng7 = sh.Range("A28:j45")
'Test if there enough rows in the DestSh to copy all the data
If Last + CopyRng1.Rows.Count > DestSh.Rows.Count Then
MsgBox "There are not enough rows in the Destsh"
GoTo ExitTheSub
End If
'This example copies values/formats, if you only want to copy the
'values or want to copy everything look at the example below this macro
DestSh.Cells(Last + 1, "A").Resize(CopyRng1.Rows.Count, CopyRng1.Columns.Count).Value = CopyRng1.Value
DestSh.Cells(Last + 1, "B").Resize(CopyRng2.Rows.Count, CopyRng2.Columns.Count).Value = CopyRng2.Value
DestSh.Cells(Last + 1, "C").Resize(CopyRng3.Rows.Count, CopyRng3.Columns.Count).Value = CopyRng3.Value
DestSh.Cells(Last + 1, "D").Resize(CopyRng4.Rows.Count, CopyRng4.Columns.Count).Value = CopyRng4.Value
DestSh.Cells(Last + 1, "E").Resize(CopyRng5.Rows.Count, CopyRng5.Columns.Count).Value = CopyRng5.Value
DestSh.Cells(Last + 1, "F").Resize(CopyRng6.Rows.Count, CopyRng6.Columns.Count).Value = CopyRng6.Value
Last = LastRow(DestSh)
DestSh.Cells(Last + 1, "F").Resize(CopyRng7.Rows.Count, CopyRng7.Columns.Count).Value = CopyRng7.Value