Я пытаюсь скопировать некоторый диапазон (таблицу) в правильном направлении, но у меня есть проблема, потому что правильное направление - это символы.Моя функция получает количество копий и количество строк в таблице (диапазон таблицы является динамическим).
Function DrawBorder(Rows As Long, Amount As Long)
Dim rng As Range
Dim WS As Worksheet
Dim firstRow As Long
Dim firstCol As Long
Dim lastRow As Long
Dim lastCol As Long
Let firstRow = 2
Let firstCol = 2
Let lastRow = Rows + 2
Let lastCol = 4
Set WS = Sheets("Sheet1")
Set rng = WS.Range("B" & firstRow & ":" & "D" & lastRow)
'Borders of the cells inside the range
rng.Borders.LineStyle = xlContinuous
'Border of the range as a whole with double lines
rng.Borders(xlEdgeTop).LineStyle = xlContinuous
rng.Borders(xlEdgeTop).Weight = xlThick
rng.Borders(xlEdgeBottom).LineStyle = xlContinuous
rng.Borders(xlEdgeBottom).Weight = xlThick
rng.Borders(xlEdgeLeft).LineStyle = xlContinuous
rng.Borders(xlEdgeLeft).Weight = xlThick
rng.Borders(xlEdgeRight).LineStyle = xlContinuous
rng.Borders(xlEdgeRight).Weight = xlThick
' Paste to multiple destinations
rng.Copy Destination:=Sheet1.Range("F" & firstRow & ":" & "H" & lastRow)
rng.Copy Destination:=Sheet1.Range("J" & firstRow & ":" & "L" & lastRow)
rng.Copy Destination:=Sheet1.Range("N" & firstRow & ":" & "P" & lastRow)
rng.Copy Destination:=Sheet1.Range("R" & firstRow & ":" & "T" & lastRow)
End Function
Я хочу сделать это в цикле, но я не знаю, как увеличить назначение столбцов.
Это то, что мне нужно:

Последний цикл, который я использую:
Dim i As Long
For i = 0 To Amount - 1 'copy "Amount" times
rng.Copy Destination:=rng.Offset(ColumnOffset:=4 * i)
Next i
Спасибо всем!