Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Is there any way to hide teh blank rows in excel without using loop ?

Is there any way to hide teh blank rows in excel without using loop ?

Scheduled Pinned Locked Moved C#
question
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abcurl
    wrote on last edited by
    #1

    Is there any way to hide the blank rows in excel without using loop ?

    T 1 Reply Last reply
    0
    • A abcurl

      Is there any way to hide the blank rows in excel without using loop ?

      T Offline
      T Offline
      TheFoZ
      wrote on last edited by
      #2

      If the blank rows are within the data, you can apply the auto filter within code to do this. It will leave you with the autofilter selectors on the sheet but it is the quickest method. Just record a macro of you doing the task and you will have the basis for the code.

      The FoZ

      A 1 Reply Last reply
      0
      • T TheFoZ

        If the blank rows are within the data, you can apply the auto filter within code to do this. It will leave you with the autofilter selectors on the sheet but it is the quickest method. Just record a macro of you doing the task and you will have the basis for the code.

        The FoZ

        A Offline
        A Offline
        abcurl
        wrote on last edited by
        #3

        i am exporting the data to excel and finally i get the blank row below the data. I want to hide those rows without iteration

        T 1 Reply Last reply
        0
        • A abcurl

          i am exporting the data to excel and finally i get the blank row below the data. I want to hide those rows without iteration

          T Offline
          T Offline
          TheFoZ
          wrote on last edited by
          #4

          If the rows are at the end, you can find the row of the last cell that contains any data. In VBA it looks like this

          Dim lastCell As Range
          Set lastCell = Range("A1").SpecialCells(xlCellTypeLastCell)

          From that you can work your way up deleting the blank rows. It still uses iteration but there are fewer.

          The FoZ

          A 1 Reply Last reply
          0
          • T TheFoZ

            If the rows are at the end, you can find the row of the last cell that contains any data. In VBA it looks like this

            Dim lastCell As Range
            Set lastCell = Range("A1").SpecialCells(xlCellTypeLastCell)

            From that you can work your way up deleting the blank rows. It still uses iteration but there are fewer.

            The FoZ

            A Offline
            A Offline
            abcurl
            wrote on last edited by
            #5

            around 60,000 rows are blank, this means it will create performance issue

            T 1 Reply Last reply
            0
            • A abcurl

              around 60,000 rows are blank, this means it will create performance issue

              T Offline
              T Offline
              TheFoZ
              wrote on last edited by
              #6

              Are they just the normal blank rows you get in any Excel spreadsheet? Or do they actual contain something and is making your workbook file size huge?

              The FoZ

              A 1 Reply Last reply
              0
              • T TheFoZ

                Are they just the normal blank rows you get in any Excel spreadsheet? Or do they actual contain something and is making your workbook file size huge?

                The FoZ

                A Offline
                A Offline
                abcurl
                wrote on last edited by
                #7

                normal. Suppose i send 9 rows to excel through datatable class. and the remaining 65000 are blank, i wanted to hide these blank rows

                T 1 Reply Last reply
                0
                • A abcurl

                  normal. Suppose i send 9 rows to excel through datatable class. and the remaining 65000 are blank, i wanted to hide these blank rows

                  T Offline
                  T Offline
                  TheFoZ
                  wrote on last edited by
                  #8

                  If you now where the data ends, you will be able to create a range object that starts from the last row and finishes at the end of the spreadsheet then set the hidden property to true. Something like rangeToHide.EntireRow.Hidden = true;

                  The FoZ

                  A 1 Reply Last reply
                  0
                  • T TheFoZ

                    If you now where the data ends, you will be able to create a range object that starts from the last row and finishes at the end of the spreadsheet then set the hidden property to true. Something like rangeToHide.EntireRow.Hidden = true;

                    The FoZ

                    A Offline
                    A Offline
                    abcurl
                    wrote on last edited by
                    #9

                    Thanks it worked

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups