Kalkomania
New Member
- Joined
- Aug 30, 2022
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
Hello all! It's a pleasure to be here, love this site.
i need some help with this excel file,
i have to copy al the data between C9 and L (L=number of times of copies), from sheet 1 too sheet 2 in that same order with all the values and formats from sheet 1.
in sheet 2 has to be copied all the data.
right now i am using the folowing code that i copied from another threat but i cant modify it to copy to he sheet 2 with all formats and values.
Can you please help me? Thank you in advance!
Sub CopyLines()
Dim srcSht As Worksheet, destSht As Worksheet
Dim srcRng As Range, destRng As Range
Dim srcLRow As Long, destLRow As Long
Dim srcArr As Variant, destArr() As Variant
Dim NoOfLines As Long, destRow As Long
Dim iRow As Long, iCol As Long, iLines As Long
Set srcSht = Worksheets("Sheet1")
Set destSht = Worksheets("Sheet2")
srcLRow = srcSht.Range("C" & Rows.Count).End(xlUp).Row
Set srcRng = srcSht.Range("C9:L" & srcLRow)
srcArr = srcRng
NoOfLines = Application.Sum(srcRng.Columns(10))
ReDim destArr(1 To NoOfLines, 1 To UBound(srcArr, 2))
For iRow = 1 To UBound(srcArr)
For iLines = 1 To srcArr(iRow, 10)
destRow = destRow + 1
For iCol = 1 To UBound(srcArr, 2)
destArr(destRow, iCol) = srcArr(iRow, iCol)
Next iCol
Next iLines
Next iRow
destSht.Range("C9").Resize(UBound(destArr, 1), UBound(destArr, 2)).Value = destArr
End Sub
i need some help with this excel file,
i have to copy al the data between C9 and L (L=number of times of copies), from sheet 1 too sheet 2 in that same order with all the values and formats from sheet 1.
in sheet 2 has to be copied all the data.
right now i am using the folowing code that i copied from another threat but i cant modify it to copy to he sheet 2 with all formats and values.
Can you please help me? Thank you in advance!
Sub CopyLines()
Dim srcSht As Worksheet, destSht As Worksheet
Dim srcRng As Range, destRng As Range
Dim srcLRow As Long, destLRow As Long
Dim srcArr As Variant, destArr() As Variant
Dim NoOfLines As Long, destRow As Long
Dim iRow As Long, iCol As Long, iLines As Long
Set srcSht = Worksheets("Sheet1")
Set destSht = Worksheets("Sheet2")
srcLRow = srcSht.Range("C" & Rows.Count).End(xlUp).Row
Set srcRng = srcSht.Range("C9:L" & srcLRow)
srcArr = srcRng
NoOfLines = Application.Sum(srcRng.Columns(10))
ReDim destArr(1 To NoOfLines, 1 To UBound(srcArr, 2))
For iRow = 1 To UBound(srcArr)
For iLines = 1 To srcArr(iRow, 10)
destRow = destRow + 1
For iCol = 1 To UBound(srcArr, 2)
destArr(destRow, iCol) = srcArr(iRow, iCol)
Next iCol
Next iLines
Next iRow
destSht.Range("C9").Resize(UBound(destArr, 1), UBound(destArr, 2)).Value = destArr
End Sub