Hello Winner_texas,
Question: 1. How do I change the name of the the checkboxes in Cell A1 in your solution? For example if I would like to change it to "Hide Current" instead of "Current"..and similarly for others.
Answer 1: These are Control Toolbox Check Boxes .- Open the VB Editor by pressing ALT+F11
- Place VB in Design Mode using ALT+R then pressing M
- Under the VBAProject for your workbook, look for the Microsoft Excel Objects
- Double Click Sheet1(Sheet1)
- Open the Properties window using F4
- Click the drop down in the Properties - Sheet1 window.and Click CheckBox1
- Find the Caption property in the list. Select the text in cell to right and type in your new caption.
- Click the drop down in the Properties - Sheet1 and repeat steps G and H for the remaining check boxes.
Question 2: Can you give me a little logic around your code lines so that if I need to edit/learn, I can do it myself. For example, what if I instead of "Improv", I have "Improvement" in all the lines. I didn't see a reference to word itself in the code. I am wondering if it is dependent on the control name itself.
Answer 2: The macro HideRows takes two arguments. The first argument is the Search Term and the second is the unique ID number used to identify the control. In the example below, the Control's Caption is the Search Term and 1 is the Control's ID.
The search is not case sensitive and you can include wildcard characters in the search term. If you want to look for for either Improv or Improvement then your search term would be "improv*". This will match all words beginning with "improv" like "improve", "improvise", and "improvement".
The Control's ID is used an index into the Public array HiddenRng. This array contains the Range (rows) that were hidden by the macro. Storing this range allows the macro to restore the hidden rows when the check box is cleared.
Question 3: Later on in this development, if I have another condition such as - Hide all rows which have "Final" word in the text. How do I replicated what you have done.
Answer 3: If you add another Check Box to hide rows with "Final" in them it look like this.
Module1 Code
You also need to increase the size of the array HiddenRng to 1 less than the number of controls you have on the sheet . That is because this is a zero based array.
Bookmarks