ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros in Excel (https://www.excelbanter.com/excel-programming/309679-macros-excel.html)

brfiel

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

Norman Jones

Macros in Excel
 
Hi Brfiel,

Try something like:

If Not Range("A1").Value Range("A2").Value Then
Range("A1").EntireRow.Delete
End If


---
Regards,
Norman



"l" wrote in message
...
How can I write a macro that will delte a row in an IF funtion if the
logic
is false?




Nick Hodge

Macros in Excel
 
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
HIS


"brfiel" wrote in message
...
How can I write a macro that will delte a row in an IF funtion if the
logic
is false?




brfiel

Macros in Excel
 
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.

"Nick Hodge" wrote:

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
HIS


"brfiel" wrote in message
...
How can I write a macro that will delte a row in an IF funtion if the
logic
is false?





Nick Hodge

Macros in Excel
 
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
HIS


"brfiel" wrote in message
...
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.

"Nick Hodge" wrote:

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
HIS


"brfiel" wrote in message
...
How can I write a macro that will delte a row in an IF funtion if the
logic
is false?







brfiel

Macros in Excel
 
Sort would work just fine. Can't believe I didn't think of that.
Thanks a bunch.
Bob

"Nick Hodge" wrote:

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
HIS


"brfiel" wrote in message
...
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.

"Nick Hodge" wrote:

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
HIS


"brfiel" wrote in message
...
How can I write a macro that will delte a row in an IF funtion if the
logic
is false?








All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com