+ Reply to Thread
Results 1 to 4 of 4

Delete columns depending on the number of rows.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-25-2012
    Location
    CT
    MS-Off Ver
    Excel 2016
    Posts
    134

    Delete columns depending on the number of rows.

    Hi All,

    I have a workbook, with a worksheet "Summary". In this worksheet "Summary" I would like to delete all columns that have less than 100 rows. Please see the attached file

    Thanks in advance for your help.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Delete columns depending on the number of rows.

    Sub a()
    Lastcol = Cells(3, Cells.Columns.Count).End(xlToLeft).Column
    For col = Lastcol To 2 Step -1
      If Cells(Rows.Count, col).End(xlUp).Row < 100 Then
         Columns(col).Delete
      End If
    Next
    End Sub
    If solved remember to mark Thread as solved

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete columns depending on the number of rows.

    Maybe:

    Sub TallOne()
    Dim i As Long
    For i = 22 To 2 Step -1
        If Cells(Rows.count, i).End(3)(1).Row < 100 Then Columns(i).Delete
    Next i
    End Sub

  4. #4
    Forum Contributor
    Join Date
    01-25-2012
    Location
    CT
    MS-Off Ver
    Excel 2016
    Posts
    134

    Re: Delete columns depending on the number of rows.

    Hi patel45,

    it works perfectly thanks again.

    I have another questions (but not sure should I asked here or open a new thread). In the same file after deleting all the columns that have number of rows <100. I would like to sort the data according to column (D, G, J, ....).

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Delete rows depending on date
    By danieldaniel1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-06-2013, 11:56 AM
  2. Combining multiple rows from 2 columns into sorted columns depending on 1st columns value
    By Dexamphetamine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-11-2013, 10:00 AM
  3. Generate Columns depending on the number of rows filled(VBA / BDH function)
    By bryan444 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-29-2012, 04:27 AM
  4. delete rows depending on value in two column
    By meslija in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2011, 07:05 AM
  5. [SOLVED] How to delete a set of rows depending on Value
    By msbutton27 in forum Excel General
    Replies: 1
    Last Post: 01-15-2006, 01:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1