Hello all,
I found a macro to move a row to another tab in same workbook based upon whether there was a particular value.
I edited the sheet names and then cell reference range to a column in my workbook.
The macro did move the correct rows to the second tab, however, it left behind blank rows where it had cut the data from.
Note: This was not a very quick running macro - don't know if it is how written or just my computer speed. Sheet had less than 500 rows.
After running, I had to filter by blanks and then delete rows to get them out of Current tab.
When the macro is run, I would like the macro to automatically delete the row from "Current" tab after moving row to "Gone..." tab.
I would imagine I just need to add a line, but I am very new to learning macros.
Any help would be appreciated.
In advance, thank you for your time and help!
Here is my current macro:
Sub Get_Rid_of_X()
Dim Check As Range, r As Long, lastrow2 As Long, lastrow As Long
Application.ScreenUpdating = False
lastrow = Worksheets("CURRENT").UsedRange.Rows.Count
lastrow2 = Worksheets("Gone or Not Needed").UsedRange.Rows.Count
If lastrow2 = 1 Then lastrow2 = 0
For r = lastrow To 2 Step -1
If Range("B" & r).Value = "X" Then
Rows(r).Cut Destination:=Worksheets("Gone or Not Needed").Range("A" & lastrow2 + 1)
lastrow2 = lastrow2 + 1
Else:
End If
Next r
Application.ScreenUpdating = True
End Sub
I found a macro to move a row to another tab in same workbook based upon whether there was a particular value.
I edited the sheet names and then cell reference range to a column in my workbook.
The macro did move the correct rows to the second tab, however, it left behind blank rows where it had cut the data from.
Note: This was not a very quick running macro - don't know if it is how written or just my computer speed. Sheet had less than 500 rows.
After running, I had to filter by blanks and then delete rows to get them out of Current tab.
When the macro is run, I would like the macro to automatically delete the row from "Current" tab after moving row to "Gone..." tab.
I would imagine I just need to add a line, but I am very new to learning macros.
Any help would be appreciated.
In advance, thank you for your time and help!
Here is my current macro:
Sub Get_Rid_of_X()
Dim Check As Range, r As Long, lastrow2 As Long, lastrow As Long
Application.ScreenUpdating = False
lastrow = Worksheets("CURRENT").UsedRange.Rows.Count
lastrow2 = Worksheets("Gone or Not Needed").UsedRange.Rows.Count
If lastrow2 = 1 Then lastrow2 = 0
For r = lastrow To 2 Step -1
If Range("B" & r).Value = "X" Then
Rows(r).Cut Destination:=Worksheets("Gone or Not Needed").Range("A" & lastrow2 + 1)
lastrow2 = lastrow2 + 1
Else:
End If
Next r
Application.ScreenUpdating = True
End Sub