Hello everyone!
I have a workbook with several sheets and one master sheet (named RESUMEN) that contains a summary.
The master sheet has 4 columns (A, B,C, D) and approx 5000 rows (depending on the day).
Column A = store numbers (Columns B, C and D have additional info about products sold at those stores).
My rough data consists of info for a few hundred stores. But the final product only needs to show info for 33 specific stores.
I would like to build a VBA code to keep the rows of those specific store numbers ( found in column A) i.e: 2,20,287 (there are 33 of them) and delete all rest of the rows (except the header).
I found a macro online that I have adapted but I have three problems:
1. I can only figure out how to make it work to find ONE store number and delete the rest. How can I make it work to find & keep multiple numbers?
2. Is there a way that I can keep my header?
3. Right now this code runs on whichever sheet is open at the time. I need to make this code work only on the sheet named RESUMEN.
I hope this all makes sense. I am new to excel and very new to VBA so any help and/or explanation would be very much appreciated!
Code so far (credit to John Davis):
Sub DeleteRows()
Dim lr As Long
Dim i As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If Range("A" & i) <> "20" Then
Range("A" & i).EntireRow.Delete
End If
Next i
End Sub
Bookmarks