+ Reply to Thread
Results 1 to 11 of 11

Deleting rows macro

  1. #1
    Registered User
    Join Date
    07-05-2012
    Location
    Ontario, Canade
    MS-Off Ver
    Excel 2010
    Posts
    88

    Deleting rows macro

    Hey,

    I have this macro which i use to delete rows on my spreadsheet. I delete the row if the is no number in the specified column. My issue is it only deletes the empty rows on the botton, and doesnt do it throughout the spread sheet. Also, It is deleting the last row even though there is a number in the specified cells.

    Please Login or Register  to view this content.
    I have attached an example sheet. For some reason, it deletes the last row like i said, and iw doesnt delete the first row, which contains a null value in the specified cell
    Attached Files Attached Files
    Last edited by Cutter; 08-22-2012 at 07:28 PM. Reason: Corrected code tags

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Deleting rows macro

    Try this

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    07-05-2012
    Location
    Ontario, Canade
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Deleting rows macro

    thanks !!!!!!

  4. #4
    Registered User
    Join Date
    07-05-2012
    Location
    Ontario, Canade
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Deleting rows macro

    how come i get an error if nothing is there?

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519
    Nothing is where?

  6. #6
    Registered User
    Join Date
    07-05-2012
    Location
    Ontario, Canade
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Deleting rows macro

    In the Range D, when no returns are entered. I get this error. but then i run it again right away, and i get no error:S so i close it and try it again and same thing.

    Method "Union" of object'_Global' failed

    Now i have never used the union function before can you explain to me what it is and what it does? and what it does for this piece of code?

    Set RangeToDelete = Union(RangeToDelete, Cells(Ptr, "A")) Is where it stops
    Last edited by mike02; 08-23-2012 at 11:53 AM.

  7. #7
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519
    Can upload the workbook giving you the issues ?

  8. #8
    Registered User
    Join Date
    07-05-2012
    Location
    Ontario, Canade
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Deleting rows macro

    pardon me? what do you mean?

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519
    Can you upload the workbook that the code is giving you issues

  10. #10
    Registered User
    Join Date
    07-05-2012
    Location
    Ontario, Canade
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Deleting rows macro

    the work book is set up the same as the one i have upoaded earlier.

  11. #11
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Deleting rows macro

    I dont know cause If I download the file again and use the code I get know errors at all. Even on a blank sheet I get no error's. maybe your workbook is corrupt. Just a guess try restarting your computer and run the code. Like I said I get no errors

+ Reply to 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