Forum

How to check for nu...
 
Notifications
Clear all

How to check for number pattern in a workbook

12 Posts
2 Users
0 Reactions
122 Views
(@yemrovic)
Posts: 34
Eminent Member
Topic starter
 

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

 
Posted : 24/09/2020 11:58 am
(@purfleet)
Posts: 412
Reputable Member
 

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

 
Posted : 24/09/2020 1:28 pm
(@yemrovic)
Posts: 34
Eminent Member
Topic starter
 

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.

 
Posted : 24/09/2020 4:57 pm
(@purfleet)
Posts: 412
Reputable Member
 

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

 
Posted : 25/09/2020 4:31 pm
(@yemrovic)
Posts: 34
Eminent Member
Topic starter
 

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

 

Regards,

Vic

 
Posted : 26/09/2020 4:24 am
(@purfleet)
Posts: 412
Reputable Member
 

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!

 
Posted : 27/09/2020 4:29 am
(@yemrovic)
Posts: 34
Eminent Member
Topic starter
 

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

   

 
Posted : 29/09/2020 7:24 am
(@yemrovic)
Posts: 34
Eminent Member
Topic starter
 

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

 
Posted : 30/09/2020 11:47 am
(@purfleet)
Posts: 412
Reputable Member
 

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

 
Posted : 30/09/2020 2:09 pm
(@yemrovic)
Posts: 34
Eminent Member
Topic starter
 

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

 
Posted : 30/09/2020 3:56 pm
(@purfleet)
Posts: 412
Reputable Member
 

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

It now works with 4 rows

 
Posted : 04/10/2020 4:02 pm
(@yemrovic)
Posts: 34
Eminent Member
Topic starter
 

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

 
Posted : 05/10/2020 5:35 am
Share: