VBA – Excel – Activate Sheet Based on Value on Another Sheet

With this macro we do not actually add something new – it simply does something, which is quite useful if you are working with big documents where you should select the data, based on different values.

In the current example, we declare a string, then we fill the string with a value from a cell and we activate the sheet with the corresponding name. So, three actions represented in three lines in VBA code as follows:

If you write “Sheet2” in cell A1 in Sheet1 and you run the macro, Sheet2 would be selected. It may seem really meaningless, but there are cases when you need to activate different sheets, based on different values and then carry out calculations and actions in those sheets. Enjoy it!

Tagged with: ,