how to identify runs of 6 consecutive numbers in adjacent cells...

jimmyt83

New Member
Joined
Jun 28, 2010
Messages
7
Hi, after some help with identifying data in a large spreadsheet. (i'm using excel 2000 XP i think) I've used a formula i found on this site to identify the count of repeat data i have, which is nicely listed from 1 - about 50. Now i want to identify where there occurs runs of over 6 consecutive numbers in adjoining cells and higlight this info.

e.g.
1. 1
2. 2
3. 5
4. 6
5. 7
6. 8
7. 9
8. 10 **HIGHLIGHTED or identified according to the case number
9. 1
10. 6
11. 2
12. 3

hope this is clear...? any help is much appreciated. Thank you, Jim
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi, Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG28Jun03
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("B1"), Range("B" & Rows.count).End(xlUp))
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        [COLOR="Navy"]If[/COLOR] Application.Sum(Dn.Resize(6)) = Dn * 6 + 15 [COLOR="Navy"]Then[/COLOR]
            Dn.Offset(5).Interior.ColorIndex = 6
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Thanks very much Mike for your your quick reply...Unfort i get an error message: Runtime error '13':
type mismatch

My data that i want to highligh is actually in column k, so i changed that on your formula...

I am at sea with using macros, just looked up what to do with the code, so this might be a simple error..

Cheers, Jim
 
Upvote 0
Hi, Have you got any Text in Column "K", perhaps Header in "K1", if so try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG28Jun49
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("K1"), Range("K" & Rows.count).End(xlUp))
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        [COLOR="Navy"]If[/COLOR] IsNumeric(Dn) [COLOR="Navy"]Then[/COLOR]
            [COLOR="Navy"]If[/COLOR] Application.Sum(Dn.Resize(6)) = Dn * 6 + 15 [COLOR="Navy"]Then[/COLOR]
                Dn.Offset(5).Interior.ColorIndex = 6
            [COLOR="Navy"]End[/COLOR] If
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Mick, you are a genuis! it took me 10 hours to find that data on the first spreadsheet, and now its taken 10 mins for the second!

Cheers very much! quality! :)
 
Upvote 0
one more query...
if i have filtered the data on multiple custom filters (e.g. column D is greater or eq to 3, and less or eq to 4, Column F is not 0 etc) can i then snip those selected cases out and run the macro on the filtered list?? or else how can i highlight after filtering...

Didn't think of this prob...
Cheers, Jim
 
Upvote 0
Hi, Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG29Jun32
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("K1"), Range("K" & Rows.count).End(xlUp))
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        [COLOR="Navy"]If[/COLOR] IsNumeric(Dn) And Dn.Rows.Hidden = False [COLOR="Navy"]Then[/COLOR]
            [COLOR="Navy"]If[/COLOR] Application.Sum(Dn.Resize(6)) = Dn * 6 + 15 [COLOR="Navy"]Then[/COLOR]
                Dn.Offset(5).Interior.ColorIndex = 6
            [COLOR="Navy"]End[/COLOR] If
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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