Enter number into cell and delete rows that do not contain that number in Column A

excelhelpCO

New Member
Joined
Jul 20, 2022
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
Hello, I have a worksheet where I am inputting general criteria for a project at the top, and the bottom rows are different tasks based on those inputs. Specifically, Cell C9 inputs the project type. The rows below starting at A15 include different tasks based on the project type. I want a macro that will delete rows based on the project type entered into Cell C9.

Cell C9 has 3 project type options: 1, 2, and 3.

Rows starting at 15 contain the different tasks based on the project type. Column A has 1, 2, and or 3. Some projects have more requirements than others, so Column A sorts which tasks are required based on the project type.

What I want to do is generate a macro that will delete the task rows based on what is entered into cell C9. If any cells in Column A15-A100 contains the number entered Cell C9, then I want all the rows without that number entered C9 to be deleted. For example, if C9 has 1 entered, then I want all the rows in A15-A100 without 1 to be deleted. If C9 has 2 entered, then I want all the rows in A15-A100 without 2 to be deleted. Column A could include any combination of 1, 2, and or 3. For example, Row 19 might have 1 and 3 and Row 20 might only have 2. The code would need to handle the multiple numbers in 1 cell.

This is where I am stuck. I figured I would need a button that would initiate the code after I enter 1,2, or 3 into Cell C9. However, I am not sure how to structure the if/then VBA statement to read to Cell C9, search Column A15-A100 for the matching number, then delete rows based on what does not match.

I’ve searched several forums but have not found one focused on what I’m looking for. Can someone help with this?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,545
Members
449,317
Latest member
chingiloum

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top