-
I tried the code again, and now it is copying rows 1, 2, and 4. I don't know what happened to row 3.
This is the code:
Dim strPath As String
Dim strfolderpath As String
Dim LastRow As Long
Dim iStartRowOfLastBlock As Long, iBlockRow As Long, iStartRowOfNextToLastBlock As Long
Dim shtData As Worksheet, shtResult As Worksheet, shtAnalysis As Worksheet
Dim iOffset As Long
Set shtData = Sheets("Data")
Set shtResult = Sheets("SampleResult")
Set shtAnalysis = Sheets("USRMResultsAnalysis")
iStartRowOfLastBlock = shtData.Cells(Rows.count, 1).End(xlUp).Offset(-3, 0).row
iOffset = 0
For iBlockRow = 0 To 3 ' <- 4 loops, 1 for each line
iStartRowOfLastBlock = iStartRowOfLastBlock + iBlockRow
'This is the beginning of the loop
'Flask 1
With shtResult ' I think I know my ABCs but better check
.Cells(2, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 1).Value
.Cells(4, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 2).Value
.Cells(5, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 3).Value
.Cells(1, 8 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 4).Value
.Cells(1, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 5).Value
.Cells(3, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 6).Value
.Cells(6, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 7).Value
.Cells(7, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 8).Value
.Cells(4, 7 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 9).Value
.Cells(4, 8 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 10).Value
.Cells(4, 9 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 11).Value
.Cells(12, 5 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 12).Value
.Cells(13, 5 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 13).Value
.Cells(14, 5 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 14).Value
.Cells(12, 9 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 15).Value
.Cells(13, 9 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 16).Value
.Cells(14, 9 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 17).Value
.Cells(20, 4 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 18).Value
.Cells(20, 5 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 19).Value
.Cells(21, 5 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 20).Value
.Cells(21, 4 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 20).Value
.Cells(20, 3 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 21).Value
.Cells(22, 4 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 22).Value
.Cells(20, 7 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 23).Value
.Cells(20, 8 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 24).Value
.Cells(21, 7 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 25).Value
.Cells(21, 8 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 25).Value
.Cells(20, 6 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 26).Value
.Cells(22, 7 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 27).Value
.Cells(5, 11 + iOffset).Value = shtData.Cells(iStartRowOfLastBlock, 28).Value
End With
iOffset = iOffset + 15
'---------------------------------------------------------------------------------------------------------------------ROWS or COLUMNS -- I did columns
Next iBlockRow ' <-- I want the loop to go to the next rows (from the bottom most row going -3, -2, -1, 0) and scoot over 10 rows to paste.
ThisWorkbook.Sheets("SampleResult").Activate
End With
End With
End With
End If
'This part goes from shtResult to shtAnalysis which has the same layout as shtData, so I figured ishould be able to flip the previous code and apply it.
iOffset = 0
For iBlockRow = 0 To 3 ' <- 4 loops, 1 for each line
iStartRowOfLastBlock = iStartRowOfLastBlock + iBlockRow
iStartRowOfLastBlock = shtAnalysis.Cells(Rows.count, 1).End(xlUp).Offset(3, 0).row
With shtAnalysis
shtResult.Cells(iStartRowOfLastBlock, 1).Value = .Cells(2, 3 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 2).Value = .Cells(4, 3 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 3).Value = .Cells(5, 3 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 4).Value = .Cells(1, 8 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 5).Value = .Cells(1, 3 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 6).Value = .Cells(3, 3 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 7).Value = .Cells(6, 3 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 8).Value = .Cells(7, 3 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 9).Value = .Cells(4, 7 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 10).Value = .Cells(7, 8 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 11).Value = .Cells(31, 6 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 12).Value = .Cells(31, 7 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 13).Value = .Cells(31, 8 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 14).Value = .Cells(32, 6 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 15).Value = .Cells(32, 7 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 16).Value = .Cells(32, 8 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 17).Value = .Cells(41, 11 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 18).Value = .Cells(42, 11 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 19).Value = .Cells(6, 11 + iOffset).Value
shtResult.Cells(iStartRowOfLastBlock, 9).Value = .Cells(4, 7 + iOffset).Value
End With
iOffset = iOffset + 15
iStartRowOfLastBlock = shtAnalysis.Cells(Rows.count, 1).End(xlUp).Offset(3, 0).row
Next iBlockRow
Call DataGen.PDFActiveSheetNoPromptCheck
Application.ScreenUpdating = False
'NEXT ONE
StarchAnalysisWkst.TextBox3 = "Run -" & NextNumber(Worksheets("Data").Range("A3:A65536")) - 3
Me.txtFile4.Text = "CISM Starch Result - " + Format(Date, "yy-mmm-dd-w") + "-" + TextBox3.Value + "-D"
Me.txtFile3.Text = "CISM Starch Result - " + Format(Date, "yy-mmm-dd-w") + "-" + TextBox3.Value + "-C"
Me.txtFile2.Text = "CISM Starch Result - " + Format(Date, "yy-mmm-dd-w") + "-" + TextBox3.Value + "-B"
Me.txtFile1.Text = "CISM Starch Result - " + Format(Date, "yy-mmm-dd-w") + "-" + TextBox3.Value + "-A"
StarchAnalysisWkst.TextBox1 = Date
Application.ScreenUpdating = True
On Error Resume Next
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules