ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Question: IF value in M 0, set O="Delete" (https://www.excelbanter.com/excel-programming/393430-vba-question-if-value-m-0-set-o%3D-delete.html)

porter444

VBA Question: IF value in M 0, set O="Delete"
 
In my worksheet I have several rows that I want to delete based on a flag
value from other calculations. What I need to do is set the value in column
O to "delete", for the corresponding row, IF the value in column M is 0.

Logic is like this:

IF M 0, then set O="Delete"

Can you help?

Thanks in advance!

Scott

Wigi

VBA Question: IF value in M 0, set O="Delete"
 
Hi

You could use an Autofilter, to filter out the strictly positive values in
column M.

Then go to column O, select the whole column, hit F5 Special... visible
cells, hit Delete.


--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"porter444" wrote:

In my worksheet I have several rows that I want to delete based on a flag
value from other calculations. What I need to do is set the value in column
O to "delete", for the corresponding row, IF the value in column M is 0.

Logic is like this:

IF M 0, then set O="Delete"

Can you help?

Thanks in advance!

Scott


Vergel Adriano

VBA Question: IF value in M 0, set O="Delete"
 
Scott,

Try something like this:

Sub test()
Dim c As Range
For Each c In Application.Intersect(ActiveSheet.UsedRange,
ActiveSheet.Range("M:M"))
If IsNumeric(c.Value) And c.Value 0 Then
c.Offset(0, 2).Value = "delete"
End If
Next c
End Sub



--
Hope that helps.

Vergel Adriano


"porter444" wrote:

In my worksheet I have several rows that I want to delete based on a flag
value from other calculations. What I need to do is set the value in column
O to "delete", for the corresponding row, IF the value in column M is 0.

Logic is like this:

IF M 0, then set O="Delete"

Can you help?

Thanks in advance!

Scott



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

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