clohuff
New Member
- Joined
- Apr 19, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
I have a macro that allows me to delete certain rows based off a specific text value from a specific sheet only, this seems to only work as long as I am active on the sheet named Apple however I want to be able to run a macro enabled button while I am on a different sheet and I keep receiving an error.
For reference the sheet named where I need the rows to be deleted from is named Apple and its deleting rows if column A contains the verbiage blue
My code:
Sub DeleteRow
lastrow= ThisWorkbook.Worksheets("Apple").Cells(Row.Count,1).End(xlUp).Row
For i=lastrow To 2 Step by -1
If ThisWorkbook.Worksheets("Apple").Cells(i,1).Value="Blue" Then
Rows(i).Delete
End If
ThisWorkbook.Worksheets("Apple").Cells (1,1).Select
Next
End Sub
Any suggestions would help thank you!
For reference the sheet named where I need the rows to be deleted from is named Apple and its deleting rows if column A contains the verbiage blue
My code:
Sub DeleteRow
lastrow= ThisWorkbook.Worksheets("Apple").Cells(Row.Count,1).End(xlUp).Row
For i=lastrow To 2 Step by -1
If ThisWorkbook.Worksheets("Apple").Cells(i,1).Value="Blue" Then
Rows(i).Delete
End If
ThisWorkbook.Worksheets("Apple").Cells (1,1).Select
Next
End Sub
Any suggestions would help thank you!