Hi All
I'm having a strange problem with the below macro. The macro is an adaptation of a macro I found on this site created by Fluff
It has two problems
1
It is copying and pasting the wrong rows from from sheet1 to sheet2. It is copying rows where there is a 0 rather than 1 or over to sheet2 (what is stranger it is copying the correct number of rows and the ones it is copying are the same number of rows apart.
2
If I copy B:D it it actually copies C:E (hence in the code I have used A:C and this gives me B:D which is what I require)
Any ideas where i Have gone wrong??
Kind regards
Paul
I'm having a strange problem with the below macro. The macro is an adaptation of a macro I found on this site created by Fluff
It has two problems
1
It is copying and pasting the wrong rows from from sheet1 to sheet2. It is copying rows where there is a 0 rather than 1 or over to sheet2 (what is stranger it is copying the correct number of rows and the ones it is copying are the same number of rows apart.
2
If I copy B:D it it actually copies C:E (hence in the code I have used A:C and this gives me B:D which is what I require)
Any ideas where i Have gone wrong??
Kind regards
Paul
VBA Code:
Sub cleanup()
Dim rng As Range
Dim cell As Range
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheet1
Set ws2 = Sheet2
Set rng = ws1.Range("B3:B49")
For Each cell In rng
If cell.Value >= 1 Then
cell.Range("A" & ActiveCell.Row & ":C" & ActiveCell.Row).Copy
If ws2.Range("B16").Value = "" Then
ws2.Range("B16").PasteSpecial xlPasteValues
Else
ws2.Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
End If
End If
Next cell
End Sub