Select Customize Ribbon and check the Developer option from Main Tabs. Note: If you can’t see the Developer ribbon, from the File menu, go to Options. But you can replace the row number from “8” in line 3 to the row number that you plan to put your ‘X’s in. In our example, we want to hide the columns that contain an ‘X’ in row 8.Copy the above lines of code and paste them into the new module window. You should see a new module window open up. Make sure ‘ThisWorkbook’ is selected under the VBA project with the same name as your Excel workbook.If you don’t see the Project Explorer, click on View->Project Explorer Once your VBA window opens, you will see all your project files and folders in the Project Explorer on the left side.From the Developer menu ribbon, select Visual Basic.To enter the above code, all you have to do is copy it and paste it in your developer window. Writing the VBA Codeįor Each cell In ("8").Cells It should essentially analyze each cell from A8 to F8 and adjust the ‘Hidden’ attribute of the column that you want to hide. Say you have columns containing sales figures for Monday through Friday, and you want to run a macro to hide all columns that have the letter X in row 8.įor this, we need a macro that will loop through each cell of row 8 and hide the corresponding column. Let us use the following dataset to demonstrate: It can be a number, a letter, a word, or even a phrase. The value, based on which you want to hide the columns, can be anything you like. In this example, we will show you how to hide all columns that contain a particular value in a given cell. Hiding Columns Based on Cell Value when Macro is Executed
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |