Closed Thread
Results 1 to 13 of 13

how to delete unnecessary rows ??

  1. #1
    colwyn
    Guest

    how to delete unnecessary rows ??

    I want to delete unnecessary rows in a 332324 row s/s containing 30000+ ranges of data of differing sizes.
    The minimum necessary requirement for each range is 4 rows. There should also be one blank row between each range.
    Does anyone know code which will carry out such an instruction please?
    By way of illustration, I enclose a small attachment.
    Big thanks.
    Colwyn.
    Last edited by colwyn; 12-31-2008 at 06:57 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You really need to delete all those empty modules!

    Try this code

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You really need to delete all those empty modules!

    Try this code

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284
    Please Login or Register  to view this content.

  5. #5
    colwyn
    Guest
    Bob Phillips, thanks a lot but your code sets a limit of 4 rows per range whereas I wanted a minimum of 4 rows.

    RoyUK, thanks. That does exactly what I wanted it to do.
    Just one thing, when you say "You really need to delete all those empty modules!" do you mean blank columns??
    Big thanks.
    Colwyn.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by colwyn View Post
    Bob Phillips, thanks a lot but your code sets a limit of 4 rows per range whereas I wanted a minimum of 4 rows.

    RoyUK, thanks. That does exactly what I wanted it to do.
    Just one thing, when you say "You really need to delete all those empty modules!" do you mean blank columns??
    Big thanks.
    Colwyn.
    I mean that you have several empty modules in the workbook -empty code modules
    Last edited by royUK; 12-17-2008 at 01:05 PM.

  7. #7
    colwyn
    Guest
    royUK, thanks. I'm totally lost - what are "empty modules in the workbook -0 empty code modules".
    Sorry but I just don't have a clue what you are saying. Can you explain please ??
    Big thanks.
    Colwyn.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you open the VB Editor you will see that you have a list of modules - most of them are empty, i.e. they contain no code

  9. #9
    colwyn
    Guest
    royUK, thanks for your help and advice. I was unaware of these modules and will look it up on the net and make necessary corrections.
    Big thanks.
    Colwyn.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You must have added them from the VBA Insert menu

  11. #11
    colwyn
    Guest

    royUK - help with your code please !!!

    royUK the code you gave worked when supplied. However, I've just applied it (repeatedly) and it keeps refusing to run!
    A 'compile error' box comes up with the message:
    "With object must be user-defined type, Object, or Variant"

    Your code was:
    Please Login or Register  to view this content.

    I changed the
    With Sheet1
    line to:
    With 1998-2003

    When I click 'Run' the error box comes up.
    Also, whilst 'With' is highlighted, 1998-2003 has changed to 1998 - 2003.

    Any idea why it isn't working.
    I'm using Excel 2007.
    Big thanks.
    Colwyn.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Sheet1 as used in Roy's code is the CodeName of a worksheet -- what you see in the project Explorer window to the left of the sheet name. A workbook with two sheets starts out as:

    Sheet1 (Sheet1)
    Sheet2 (Sheet2)

    Rename Sheet1 as mySheet and you'll see

    Sheet1 (mySheet)
    Sheet2 (Sheet2)

    The CodeName is unchanged; only the sheet name changes. Delete Sheet1, rename Sheet2 as Sheet1, and you have

    Sheet2 (Sheet1)

    Poof -- no sheet with CodeName Sheet1, even though you may have a sheet named Sheet1, and the code errors.

    Sooo .... change the code to either use the CodeName for the worksheet of interest, or use the worksheet name:

    Please Login or Register  to view this content.
    Last edited by shg; 12-28-2008 at 03:52 PM.
    Entia non sunt multiplicanda sine necessitate

  13. #13
    colwyn
    Guest
    shg big thanks for that. Most helpful.
    Colwyn.

Closed Thread

Thread Information

Users Browsing this Thread

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

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