Solved

conditional row delete

Posted on 2013-10-23
4
188 Views
Last Modified: 2013-10-29
I have a worksheet with X number of columns (this can run up to 200 columns or more), but the exact number is variable. So, first have to calculate number of rows that happen to be in this particular worksheet.

Then, I want to go through each row and check the value initially in the the ninth column (I), then every 12 columns (U, AG...) thereafter to the end. The number of the last column having been determined in step 1 above. However, the end column will not be the last column checked. The last column will be about 4 columns after the last column checked. For example, because we are checking every 12 columns after column I, the last checked column ( I know this for certain ) will not be the last column in the worksheet, but will be about 4 columns before the end.

For a given row, if all values in all columns that were checked were below 2 and less than -2 (between 2 and -2), then delete the row.
0
Comment
Question by:vbaabv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39595650
Can you provide a sample workbook?
0
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39595669
Here is a macro that will check your data and delete rows if every twelfth value has an absolute value equal to or less than 2, starting with cell I2.
Sub Absolution()
Dim rg As Range
Dim i As Long, j As Long, nCols As Long
Dim bDelete As Boolean
Application.ScreenUpdating = False
Set rg = ActiveSheet.UsedRange
nCols = rg.Columns.Count
For i = rg.Rows.Count To 2 Step -1      'The first row is header labels. Don't check it for absolute values
    bDelete = True
    For j = 9 To nCols Step 12
        If IsNumeric(rg.Cells(i, j).Value) Then
            If Abs(rg.Cells(i, j).Value) > 2 Then
                bDelete = False
                Exit For
            End If
        End If
    Next
    If bDelete = True Then rg.Rows(i).EntireRow.Delete
Next
End Sub

Open in new window

AbsoluteValueDeleteQ28275433.xlsm
0
 

Author Comment

by:vbaabv
ID: 39609905
Thank you very much, byundt. Checking this script requires a somewhat complex set of data, so sorry for the delay in getting back to you. This is working very well. Thank you very much for your help.
0
 

Author Closing Comment

by:vbaabv
ID: 39609906
Thank you very much. Excellent work !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question