ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to Show or Hide Multiple Rows in Excel Using A Button

Updated on September 29, 2019
excel10tutorial profile image

Excel Trainer at Excel 10 Tutorial Feel free to connect to solve your excel related problems. Thanks.

Show/hide Multiple Rows in Excel

Hiding and showing rows could be crucial in Microsoft Excel if you are working on a long workbook or you are working on your custom dashboard. In this article you’ll learn how you can create a button to hide/show multiple rows in Microsoft Excel. This isn’t a built-in feature and we are going to use Microsoft Excel VBA in this tutorial.

Why you should use this?

There are tons of alternatives in excel. Sticking to any of them requires some extra features or problem-solving capabilities. In this article you will learn how you can show/hide rows using a button. Now I know you can simply select the rows and then hide it manually. But what if your workbook is long. Will you be able to select hundreds of rows manually and then hide them? Let's say you have done that. What if you need to show those hidden rows? In short you can solve almost anything in excel but solving problems fast and efficiently is something that matters.

Now you can ask several questions or even ask for several new features along with this solution. For example, you need to hide rows on different worksheets or even from different workbooks. Now that's why you have awarded with a gift named COMMENT. This article indicates a problem and solves it. If you need anything you can ask in the comment and I'll get back to you with a solution.

You can use this procedure along with any other macro and also you can create several buttons to show/hide rows using this procedure. With that said let's get started.

Step 1

First, we’re going to need a button so that we can assign some Visual Basic Coding to that button. In order to do that we’ll have to click on the Developer Tab. Developer tab is placed at the ribbon at the top of your opened workbook. If you can’t find it there then you’ll have to activate it.

To activate developer tab on your ribbon you’ll have to go to the "Customize Ribbon" option and then activate it. Go to “File”-> Click on “Option”-> Click on "Customize Ribbon”. Find the Developer Tab from the left table and then Click on “Add”. It will add the developer tab on the Ribbon.

Once you activate the developer tab you will be access it from your ribbon.

Developer Tab

 Step 2

Click on “Insert” right under the “Developer Tab”.


Step 3

Select the "Toggle Button". Remember to use “ActiveX Control” button.

Toggle Button

Video tutorial on how to show/hide rows using a button in excel

Step 4

Draw your button. You can add stylings according to your choice. Its best you design it according to your dashboard or your workbook format. It makes it look more professional.

Design Button

Step 5

After you finished designing your button “Double Click” on the button you just created. This will open the VBE or Visual Basic Editor. This Is the place where you write your VBA code.

Open VBE & Write Code

Step 6

Delete Pre-occupied coding and paste this VBA code. Change the 5th line of the code according to your need. In this line the row numbers are stored. Add your row numbers here and make sure they are comma separated. Just like it is now inside the code.

VBA Code

Private Sub ToggleButton1_Click()

'Provided by Excel0Tutorial
    Dim xAddress As String
    Dim splitAddress As Variant
    xAddress = "1,5,8,9,10" 'change this to the row numbers
    splitAddress = Split(xAddress, ",")
    If ToggleButton1.Value Then
        For Each Var In splitAddress
            Application.ActiveSheet.Rows(Var).Hidden = True
            ToggleButton1.Caption = "Show Row"
        Next Var
        For Each Var In splitAddress
            Application.ActiveSheet.Rows(Var).Hidden = False
            ToggleButton1.Caption = "Hide Row"
        Next Var
    End If

End Sub

Step 7

Close the VBE or Visual Basic Editor. You can do that by clicking the cross on the right corner or you can Press ALT+Q on your keyboard.

Step 8

Click on the “Design Mode” button. It is placed at the top of your ribbon and under the developer tab. This will stop the designing mode. Once you are out of the designing mode your button is ready for action.

Exit Design Mode

Step 9

Click on your button and it should hide the predefined rows and if you click on the button it will show those rows.

This is how you can create a simple toggle button and use a snippet of VBA code and create an awesome feature in Microsoft Excel. This will increase your productivity for sure. It will also save a lot of time. From now on you won’t have to manually find 20 rows and then hide them. Now you can just click on your custom-made button and hide those rows.

Bonus Feature

You can use this code along with other VBA codes in your workbook. Incase you need another button to show/hide another series of rows then you can use the same code alongside your previous code. In that case you’ll have to create another button and then change the button name from the code. Also change the rows you want to hide and show. Done.

Pro Tip

Save the workbook. You’ll have to save this workbook as Excel Macro Enabled Workbook (.XLSM) format otherwise your button won’t work the next time you open the workbook. If you have any question regarding this article or if you need any article relate to Microsoft excel, you can leave a comment here. I will try my best to solve your problem.

© 2019 kazi


    0 of 8192 characters used
    Post Comment

    No comments yet.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)