Macros in Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I write a macro that will delte a row in an IF funtion if the logic
is false?
 
Hi Brfiel,

Try something like:

If Not Range("A1").Value > Range("A2").Value Then
Range("A1").EntireRow.Delete
End If
 
Strictly you can't delete a row with a worksheet function such as if, but,
given more detail on what you are actually trying to accomplish, with
examples or scenarios, I am sure we can come up with a solution for your
need

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
I want to delete a row if my If function is false and therefore would perform
no calculations. If no calculations then the row is blank and I want to
delete it. What I wondered is if I could put a macro in the third argument
of the If function that would delet the row. Does that make sense?
Thanks for your interest.
 
Sorry it took a while to get back. You cannot fire any kind of macro from a
worksheet function.

From your description it appears you are only trying to delete rows when a
cell in the column is blank.

I may not be understanding you, but you could sort on this column, the
blanks would go to the bottom and you could delete them there.

This too could be automated

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
Sort would work just fine. Can't believe I didn't think of that.
Thanks a bunch.
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top