+ Reply to Thread
Results 1 to 10 of 10

Excel Macro to delete rows problem

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    88

    Question Excel Macro to delete rows problem

    Hi,

    Anyone see why this code won't work? I want to delete rows with blank cells in column 'X'.
    Any help would be much appreciated.

    Please Login or Register  to view this content.
    Last edited by Ardiko; 09-19-2012 at 10:23 AM.

  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: Excel Macro to delete rows problem

    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
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Excel Macro to delete rows problem

    Another way

    Please Login or Register  to view this content.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Excel Macro to delete rows problem

    Try this instead...
    Please Login or Register  to view this content.
    There were too many logic errors in your code to simply patch it.
    For example:
    Cells(xrow,1) is looking at Column A not Column X
    Do Until Xrow = xlastrow wouldn't ever get there as you were subracting 1 from xrow
    xrow would go negative as soon as you found the first blank in your A columns....
    Too many errors in logic......
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Excel Macro to delete rows problem

    Hi mike,

    You line of :
    If Cells(xrow, 1).Value = "" Then
    looks at column A not X.

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

    Re: Excel Macro to delete rows problem

    Sorry I missed column X update to code

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-13-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Excel Macro to delete rows problem

    Hi - I'm very bad at coding which line do I change for it to do column 'X' and at a specific row.

    e.g. I want it to delete all rows in column 'X' with a blank so when I filter this is typically less than a 100 but could be the 50th row value to delete or the 1000th value to delete.

  8. #8
    Registered User
    Join Date
    08-13-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Excel Macro to delete rows problem

    Hi guys,

    I still haven't solved this problem. I've attached a demo file of what I need done.
    I just need the blanks gone but I can't solve debug the issue from the previous solutions.

    Any help would be greatly appreciated.

    Delete Blanks Cells.xlsm

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

    Re: Excel Macro to delete rows problem

    Try this should work

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-13-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: Excel Macro to delete rows problem

    Thanks Mike, I realised that by adding an extra column it had got pushed to Y without me knowing.

+ 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