• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

How to check for number pattern in a workbook|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / How to check for number pattern in a workbook|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosHow to check for number pattern in …
sp_PrintTopic sp_TopicIcon
How to check for number pattern in a workbook
Avatar
Vic Man
Member
Members
Level 0
Forum Posts: 36
Member Since:
January 11, 2019
sp_UserOfflineSmall Offline
1
September 24, 2020 - 1:58 am
sp_Permalink sp_Print

Hello everyone, 

 

Please i need help. 

TABLE 1
NO 1 NO 2 NO 3
23 36 15
44 20 8
52 23 99
TABLE 2
NO 1 NO 2 NO 3
41 15 87
22 8 93
35 67 56

Table one above shows a pattern in which 8 is under 15 under NO3. Now table 2 is equally showing similar pattern in which 8 is under 15 in NO2. I want to be able to search my entire workbook so that if i want to check where 8 is under 15 anywhere in my workbook, it will highlight it and refer me to the sheet where same pattern appears.

 

Please help. Thanks

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
September 24, 2020 - 3:28 am
sp_Permalink sp_Print

Its much easier if you add a workbook instead of screen dumps/text.

Try the attached, you need to select the grid you want to check then click the button. The numbers to check can be changed in K2 & k3

Sub CheckUnder()

Dim Top As Integer
Dim Bottom As Integer

Dim r As Range
Dim c As Range

Top = Range("k2")
Bottom = Range("k3")

Set r = Selection

For Each c In r

If c.Value = Top And c.Offset(1, 0) = Bottom Then
c.Offset(1, 0).Interior.Color = vbRed
c.Offset(1, 0).Font.Color = vbWhite
End If

Next c

End Sub

Avatar
Vic Man
Member
Members
Level 0
Forum Posts: 36
Member Since:
January 11, 2019
sp_UserOfflineSmall Offline
3
September 24, 2020 - 6:57 am
sp_Permalink sp_Print

hello Purfleet,

thanks so much for your response. much appreciated. However, kindly find attached the problem i am looking for solution for. in the attached, Column A to J will not change. they are static. I want a situation whereby when I enter a pattern according to column M to Q, if that pattern is available in the work book (Different sheet that I will be adding those number data), it should direct me there. Column A to J will not change. 

 

Thanks as I look forward to your help bro.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
4
September 25, 2020 - 6:31 am
sp_Permalink sp_Print

This is the reason we need the example, looking for a number and the number below is easy (as per yesterdays code).

But now the numbers can be any where in a 5*2 grid and there can be 2 or 3 numbers? That is much harder

Going to need some thinking time

Avatar
Vic Man
Member
Members
Level 0
Forum Posts: 36
Member Since:
January 11, 2019
sp_UserOfflineSmall Offline
5
September 25, 2020 - 6:24 pm
sp_Permalink sp_Print

Ok bro. Thanks so much. I look forward to a possible solution from you. Thanks for assistance.

 

Regards,

Vic

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
6
September 26, 2020 - 6:29 pm
sp_Permalink sp_Print

It not complete, but i think it captures the concept

  • You put the pattern to look for in L to U 1 or 2 rows (note this is a 1 to 10 grid and they must be in the correct columns)
  • a formula will appear in column W
  • then the cells are highlighted

I know you have multiple sheets, but is this the basic idea?

Would be interested if anyone else had better ways of doing it as i have been down numerous rabbit holes!

Avatar
Vic Man
Member
Members
Level 0
Forum Posts: 36
Member Since:
January 11, 2019
sp_UserOfflineSmall Offline
7
September 28, 2020 - 9:24 pm
sp_Permalink sp_Print sp_EditHistory

Hello Purfleet,

 

I really do not know how to thank you for this. This is great. You got the whole concept perfectly. It is working amazingly bro and this is exactly what i need. 

 

The extra behavior that i need on the sheet are;

1. I want up to 4 parameters i.e 4 rows maximum like you stated in your point 1 of your last reply. (I have shown it in the sheet (AB - AV)

2. I may decide to create extra column in-between the columns (I have shown example in the attached sheet.  Column A,B & H newly created). The addition of columns shouldn't affect the macro. KINDLY NOTE: macro will only run on NO1 TO NO10 ONLY. It will not run on any other column

3. Like I said before, i have multiple sheets and the data in each of those sheets are endless. So, I want the macro to check for any pattern in all my sheets.

 

This is the only thing needed. Once these are done, then its is fine.

 

Once again, thanks so much. You are really good.

 

Regards,

 

Vic Man

   

Avatar
Vic Man
Member
Members
Level 0
Forum Posts: 36
Member Since:
January 11, 2019
sp_UserOfflineSmall Offline
8
September 30, 2020 - 1:47 am
sp_Permalink sp_Print

Hello Purfleet,

 

Trust you are well and doing fine.

 

I haven't heard from you since the last time and i was wondering if you are okay. Sorry to bother you but please, did you by any chance saw my last message before this one and the attachment?

 

Hope to hear from you soon.

 

Thanks

 

Vic Man

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
9
September 30, 2020 - 4:09 am
sp_Permalink sp_Print

Yes i did see it and noticed that the requirements were changed again, so from a 'fairly easy find 1 number below another' or a far more complex' find various numbers in a grid' to 'find even more numbers in a grid with another number inbetween'!

I will have a look but i cant guarantee when

Avatar
Vic Man
Member
Members
Level 0
Forum Posts: 36
Member Since:
January 11, 2019
sp_UserOfflineSmall Offline
10
September 30, 2020 - 5:56 am
sp_Permalink sp_Print

Hello Purfleet,

 

Thanks for your response. I will wait till you are able to help me solve this.

Meanwhile, the extra column which i inserted (H) is just a total of NO1 to NO5. Better still, if that will be an issue, you can remove it and then make the search parameters to be just 4 rows maximum. I am makin it 4 rows just in case i decide to search for more number patterns.

 

Thanks

 

Vic Man

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
11
October 4, 2020 - 6:02 am
sp_Permalink sp_Print

I did remove the total column as it fundmentally changed the check.

It now works with 4 rows

Avatar
Vic Man
Member
Members
Level 0
Forum Posts: 36
Member Since:
January 11, 2019
sp_UserOfflineSmall Offline
12
October 4, 2020 - 7:35 pm
sp_Permalink sp_Print

Hi Purfleet,

 

Problem solved. Thanks so so so much. super grateful. Thanks for your time you dedicated and probably some sleepless nights.

 

Warm regards.

 

Vic Man

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 217
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
David du Toit
leandro barbarini
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
Forum Stats:
Groups: 3
Forums: 24
Topics: 6356
Posts: 27796

 

Member Stats:
Guest Posters: 49
Members: 32326
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.