Hi,
I have written a script that, is intended to, for each row in a range find a specific sheet, then in that sheet find the correct column, then the row that matches two criteria from the source sheet row. The inner code is supposed to copy a value from the row in the source sheet and paste it in the correct sheet-column-row.
The "sample" and "test" string has been declared and assigned values earlier in the sub.
My problem is that the code runs without any error messages but no values are copied anywhere.
I'm new here so I don't know the convention about asking for help with code, but does anyone see any obvious mistakes as to why the code isn't returning what I want it to?
Thanks for the help!
I have written a script that, is intended to, for each row in a range find a specific sheet, then in that sheet find the correct column, then the row that matches two criteria from the source sheet row. The inner code is supposed to copy a value from the row in the source sheet and paste it in the correct sheet-column-row.
Code:
Dim srcrow As Long 'Variable for row loop in source sheet
Dim sht As Long 'Variable for sheet loop
Dim col As Long 'Variable for column loop in target sheet
Dim row As Long 'Variable for row loop in target sheet
Dim LastCol As Long
Dim LastRow As Long
LastRow = Sheets("qPCR temp").Cells(Sheets("qPCR temp").Rows.Count, 1).End(xlUp).Column
For srcrow = 2 To LastRow
For sht = 7 To Sheets.Count
If sht = Sample Then
LastCol = Sheets(sht).Cells(15, Sheets(sht).Columns.Count).End(xlToLeft).Column
For col = 1 To LastCol
If Sheets(sht).Cells(15, col) = test Then
For row = 19 To 386
If Sheets(sht).Cells(row, 9).Value = Sheets("qPCR temp").Cells(srcrow, 1) And Sheets(sht).Cells(row, 10).Value = Sheets("qPCR temp").Cells(srcrow, 2) Then
Sheets(sht).Cells(srcrow, 3).Copy Sheets(sht).Cells(row, col)
End If
Next row
End If
Next col
End If
Next sht
Next srcrow
The "sample" and "test" string has been declared and assigned values earlier in the sub.
My problem is that the code runs without any error messages but no values are copied anywhere.
I'm new here so I don't know the convention about asking for help with code, but does anyone see any obvious mistakes as to why the code isn't returning what I want it to?
Thanks for the help!