Hi,
Introduction:
I am working on creating a new Excel Sheet that is populated automatically with data from an external programme but need some help in regards on how to do something that seems so simple but I can not get my head around
Issue:
I would like to create a macro that would be initialised, when:
1. A user opens up a Excel Document
2. They Click a Button
2. Which then will run a Macro that searches a column within a defined range.
3. It will look for a designated value, in this case, that value is "X".
4. Once the macro has located all cells within the designated range that contain the value "X", the rows which contain the value "X" are highlighted.
Current Solution:
Currently to do the above function, I have utilised the following Excel VBA code:
& The following Happens:
1. A user opens up a Excel Document
2. They Click a Button
3. Which then will run a Macro that searches a column within a defined range.
4. It will look for a designated value, in this case, that value is "X".
5. Once the macro has located all cells within the designated range that contain the value "X", the rows which contain the value "X" are highlighted.
6. However when there are no values with "X" within the designated range, the Macro fails.
I think the reason why the Macro fails when there is no "X" value within the designated range is due to the " 'Highlight Rows: Select entire row of Catchphrase value " part of the code. However I have not able to think of an alternative code that I could write or could modify to make sure that the Macro does not fail when there are no "X" values. I have considered utilising a IF STATEMENT along with a MSGBOX but that did not seem to work.
Other:
I have attached an example worksheet of the VBA Code that I have shown above in working practice, below:
Example - Find X Value Example.xlsm
Thank you in advance.
Sinalk
Bookmarks