Hi all!
I have 2 worksheets, one called "Consolidated" and one called "Converted".
I have a spreadsheet where I press the update button and a macro runs that searches for the word "Converted" in column E on the Consolidated spreadsheet (the original). When it finds it, the entire row will be cut and pasted onto the "Converted" worksheet.
I have managed (with some help!) to do this with my current code. However when you press the update button again, all the newly pasted rows on the Converted worksheet are deleted. (I would like when i press the update button it to NOT affect the Converted worksheet, just add any new data found on the Consolidated sheet to the Converted sheet.) I assume this is because my current code her below is NOT telling the spreadsheet to paste to the NEXT AVAILABLE EMPTY ROW. Please see my current code:
Sub All_Loops()
Dim sheetName As Variant
For Each sheetName In Array("Converted")
Sheets(sheetName).Range("A7:XFD1048576").Delete
Next sheetName
Dim w1 As Worksheet
Dim w2 As Worksheet
Dim i as Long
Set w1 = Sheets("Consolidation")
Set w2 = Sheets("Converted")
With w1
For i = .Cells(.Rows.Count, "E").End(xlUp).Row To 7 Step -1
If .Cells(i, 5) = "Converted" Then
.Rows(i).Copy w2.Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Rows(i).Delete
End If
Application.CutCopyMode = False
Next
End With
End Sub
So the problem is this line:
.Rows(i).Copy w2.Cells(Rows.Count, 1).End(xlUp).Offset(1)
I have attempted to replace this line with:
.Rows(i).Copy w2.Cells(Range("A65536")).End(x1Up).Offset(1, 0)
But there is something wrong as the code keeps breaking on that line!
Any help would be greatly appreciated. Thanks!
Bookmarks