JonathanOTAX
New Member
- Joined
- May 10, 2021
- Messages
- 3
- Office Version
- 2016
- Platform
- Windows
Hello,
I am trying to filter data based on the value of one column, I have created this macro which copies the entire row to a different sheet depending on whether the value is 0 or >0. This works fine if the data set is complete but the issue is when there are blank cells, this macro stops as soon as it hits a blank, I want it to ignore the blank and carry on.
Thank you.
I am trying to filter data based on the value of one column, I have created this macro which copies the entire row to a different sheet depending on whether the value is 0 or >0. This works fine if the data set is complete but the issue is when there are blank cells, this macro stops as soon as it hits a blank, I want it to ignore the blank and carry on.
Thank you.
VBA Code:
Sub copyrows()
Dim tfCol As Range, Cell As Object
Set tfCol = Range("G2:G999")
For Each Cell In tfCol
If IsEmpty(Cell) Then
Exit Sub
End If
If Cell.Value = 0 Then
Cell.EntireRow.Copy
Sheet4.Select
ActiveSheet.Range("A65536").End(xlUp).Select
Selection.Offset(1, 0).Select
ActiveSheet.Paste
End If
If Cell.Value > 0 Then
Cell.EntireRow.Copy
Sheet2.Select
ActiveSheet.Range("A65536").End(xlUp).Select
Selection.Offset(1, 0).Select
ActiveSheet.Paste
End If
Next
End Sub