Macro / If Function ?

crooser100

New Member
Joined
Dec 2, 2009
Messages
16
I have a problem where by I have a whole workbook containing numerical data that I need to analyse.

I am faced with an issue where I need to ignore some rows after finding data that occurs within a column.

For example....

I have say 20 rows accross and 30,000 down. In one of the columns it has either the number 1 or 2. I want to find where the data changes from a 1 to a 2, then either delete or ignore the next 20 rows worth of data, but for the whole column.

This will be an ongoing task and would be really useful to have a macro or formula to do it for me...

Any suggestions much appreciated.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi there,

Try these (assuming the column is column C and the data starts at row 2)

Delete:

Code:
Sub delete Rows()
        lRow = Range("C" & Rows.Count).End(xlUp).Row
    For i = lRow To 2 Step -1
        If Cells(i, 3).Value = 2 And Cells(i - 1, 3).Value = 1 Then Cells(i, 3).EntireRow.Delete
    Next
End Sub
Ignore 20 rows (this wont do anything with the data though):

Code:
Sub skipRows()
    lRow = Range("C" & Rows.Count).End(xlUp).Row
    For i = 2 To lRow
        If Cells(i, 3).Value = 2 And Cells(i - 1, 3).Value = 1 Then i = i + 20
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,509
Messages
6,179,192
Members
452,893
Latest member
denay

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