excelhelpCO
New Member
- Joined
- Jul 20, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- 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?
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?