VBA Code: Delete Entire Row based on Condition

jbeck

New Member
Joined
Jun 7, 2010
Messages
20
Still learning VBA - I am trying to delete an entire row based on a condition in one cell in the row. Typically I would just filter on that value and delete the rows, but I am not sure if that is a possibility in VBA code. Can you provide the code if not too complex.

Select Cell A1 if value is 100 delete entire row, else skip to next row. Then loop through each row in the spreadsheet till all rows with selected cell equal to 100 are deleted.
 
I just realised that excel 2003 cannot incorporate so many IF arguments

My formula is like that

=IF($C2="a","CASE1",IF($C2="b","CASE1",IF($C2="c","CASE1",IF($C2="d","CASE1",IF($C2="e","CASE1",IF($C2="f","CASE1",IF($C2="g","CASE1",IF($C2="h","CASE1",IF($C2="i","CASE1",IF($C2="j","OFFR",IF($C2="k","CASE1",IF($C2="-","CASE2","WOSE"))))))))))))

Is there a way to have a macro to delete the "WOSE" based on this function for columns A and B?
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try

=IF(OR($C2="a",$C2="b",$C2="c",$C2="e",$C2="f",$C2="g",$C2="h",$C2="I",$C2="k"),"CASE1",IF($C2="j","OFFR",IF($C2="-","CASE2","WOSE")))
 
Upvote 0
I require your help again. Apparently, this macro works very slowly (more than 1 hour) with data that are more than 40000 rows. My data are usually that size. Is there a way to make the macro run faster?
 
Upvote 0
Try adding the lines in red

Rich (BB code):
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'
'code
'
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
 
Upvote 0
If Column A is OFFR and Column B is WOSE & if column A is - and column B is WOSE, then that row should not be deleted. What is the macro code for that in addition to the above macro?
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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