Results 1 to 3 of 3

Excel 2003 VBA - select and delete rows

This is a discussion on Excel 2003 VBA - select and delete rows within the Excel Questions forums, part of the Question Forums category; I am opening a csv file using an excel 2003 object in VB6. I am currently looing through the rows ...

  1. #1
    New Member
    Join Date
    May 2012
    Posts
    2

    Default Excel 2003 VBA - select and delete rows

    I am opening a csv file using an excel 2003 object in VB6.

    I am currently looing through the rows in the sheet and bypassing all the rows which do not have any data in columns A to D (other data may or may not be in other columns).

    What I want to do is select and delete all rows which do not contain any information in colunms A to D BEFORE looping through the spreadsheet object to process the remaining rows which DO have data in columns A to D.

    Is there a quick way to select and delete these rows? This select/delete has to be performed in VBA/VB6 code as this is an automated process.

  2. #2
    Board Regular ClimoC's Avatar
    Join Date
    Aug 2009
    Location
    London, UK
    Posts
    571

    Default Re: Excel 2003 VBA - select and delete rows

    Code:
    For i = Range("E65000").end(xlup).row to 2 step -1
    
    if Range("A" & i).value = vbnullstring and range("B" & i).value = vbnullstring and range("C" & i).value = vbnullstring and range("D" & i).value = vbnullstring then Range("A" & i).entirerow.delete shift:=xlup
    next i
    Not pretty but works easy peasy
    "...as always, the Frisbee truly is, the window to the soul..."

  3. #3
    New Member
    Join Date
    May 2012
    Posts
    2

    Default Re: Excel 2003 VBA - select and delete rows

    ClimoC

    Thanks for the code but.....

    Thats doing what I didnt want to do i.e. looping through all the rows one by one and deleting the row. Im doing this already but just skipping over the rows with no data in the first 4 columns.

    What Im afeter is a fuction or vba code to select all blank rows as a selection/range without looping through all the rows. Once I have the selection/range, then I would assume its a simple matter of selection.delete?
    Last edited by Jurdz; May 8th, 2012 at 01:33 PM.

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com