![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 90
|
I am looking for a way to select the first row where a break in a pattern in the column is found. For example:
Row Cell Value 1 Keep 2 Keep 3 Keep 4 No I want to select row 4 because it has a different value than the cell above it (in row 3). Thank you with your help on this, SteveD |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
If A1:A4 contains...
{"Field1" ;"Keep" ;"Keep" ;"Keep" ;"No"} ...you could use an Advanced Autofilter referencing a computed Criteria using the formula... =A2<>A1 |
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
=MATCH(A2,$A$2:$A$5)+1 |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Posts: 90
|
Thanks Mark,
The spread sheet is 13,000 rows and I never know where the break off is. I'm writing a macro that will delete all of the rows that have the "no" value and below. Is there an easy way to put this in? Thanks, SteveD [ This Message was edited by: SteveD on 2002-04-18 14:23 ] |
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Posts: 90
|
Ahhh. Ok. I got it.
Thank you for your help! SteveD |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
I see the logic of using the computed criteria ... I have used it during my Lotus 123 days, but I can't make it work with Excel. I will appreciate your looking at it and providing your comments. Regards! Yogi Anand [ This Message was edited by: Yogi Anand on 2002-04-19 09:01 ] |
|
|
|
|
|
|
#8 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
|
||
|
|
|
|
|
#9 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
T H A N K S M A R K !
That was it -- I have not read the Help topic yet, but once I took the Field name out it worked just like you said it would. Regards! Yogi Anand |
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Apr 2002
Location: Minnesota
Posts: 821
|
Here is some code that I use to do just the opposite, insert a blank row when it finds a break in the pattern. Don't see why it can't be modified to delete the row instead of inserting one, but I may be wrong.
Option Explicit Dim strBottomOfList As String Dim strRecordNumber As String Sub InsertBlankRows() Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Range("A1").Select Do While ActiveCell.Value <> "" strRecordNumber = ActiveCell.Value Do Until ActiveCell.Value <> strRecordNumber ActiveCell.Offset(1, 0).Select Loop ActiveCell.EntireRow.Insert ActiveCell.Offset(1, 0).Select Loop Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|