Excel 2003 VBA - select and delete rows

L

Legacy 215653

Guest
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.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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
 
Upvote 0
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 a moderator:
Upvote 0

Forum statistics

Threads
1,214,405
Messages
6,119,323
Members
448,887
Latest member
AirOliver

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top