VBA

  • Thread starter Thread starter Howard
  • Start date Start date
H

Howard

I have a standard database which i need to upload it into my accounting
software. In this database, one column is sale amount whereby sometime the
value is NIL.

Is anyone know how to write VBA to run down that particular column to delete
those row with sale amount is NIL?

Thank you so much in advance.
 
Howard said:
I have a standard database which i need to upload it into my accounting
software. In this database, one column is sale amount whereby sometime the
value is NIL.

Is anyone know how to write VBA to run down that particular column to delete
those row with sale amount is NIL?

Can you just sort by that column and delete them
manually?
 
sub delifnil()
mc=3'column C
for i=cells(rows.count,mc).end(xlup).row to 2 step-1
if cells(i,mc)=0 then rows(i).delete
next i
end sub
 
You can do this without a macro (although you will execute a single line of
code in the Immediate Window afterwards). Select the entire column and the
click Edit/Find on the menu bar. Type NIL in the "Find what" field and then
click the "Find All" button. This will select every cell the column with the
word NIL in it... leave those cells selected and go into the VB editor
(press Alt+F11) and execute this line of code in the Immediate Window...

Selection.EntireRow.Delete

That's it... this should be much faster than using a macro (especially if
there are a lot of records involved).
 
Back
Top