I'm trying to get rows from my "Thermo" (Sheet1) worksheet copied over to the "Thermal_Report" (Sheet7) worksheet. These need to be copied over one at a time. There will be more code that I will write late on. For now I'm focused on getting the loop that will copy and paste the data working correctly. I started off by filtering the data for what I will be looking for. From there I want to select the first line and copy it over to a specified line in another worksheet. I want this to loop till it runs out of stuff to copy. Can someone take a look at this code and help me out with this. I'm getting out of range errors a the " Worksheets("Thermo").Range.src_cursor.Copy _ Destination:=dest_cursor" and I'm stumped. By the way I'm not very good at this so please be gentle.
Sub GenerateThermalReport()
Dim src_cursor As Range
Dim dest_cursor As Range
Set src_cursor = ActiveSheet.Range("A3:X3")
Set dest_cursor = Sheets("Thermal_Report").Range("A2:X2")
'Code below filters the "Thermo" sheet for only prioirty 20 problems.
With Sheet1
.Unprotect Password:="HurleyIR"
Sheet1.Range("$A$2:$X$24").AutoFilter Field:=7, Criteria1:="20"
End With
'Code Below loops through each line copying it then pasting it to the report.
Do Until IsEmpty(src_cursor(1))
Worksheets("Thermo").Range.src_cursor.Copy _
Destination:=dest_cursor
' move to next row
Set src_cursor = src_cursor.Offset(1, 0)
Loop
' Resets the filter to show all data in the sheets and protects the "Thermo" Sheet
With Sheet1
ActiveSheet.Range("$A$2:$X$24").AutoFilter Field:=7
.Protect Password:="HurleyIR"
End With
End Sub
Bookmarks