Isolate a number in string specified to the same number of digit without an extra number attached to it

Martin1978

New Member
Joined
Apr 19, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

i am a building inspector and i am creating a report with equipment which was inspected on Sheet1. On Sheet1 , i am using th column AA to write down notes numbers, per example 1,2,17,18. and each time i am reading note number 1 at AA, i am write down on my Sheet4 at Note 1 column R the page number which we find at column AE from Sheet1 and i keep on compiling the information each time the note 1 is found on Sheet1 column AA of the next row. But my problem is, i don't want to find the note 18 when i am search for note 1 only and if i put filter with a followed number, i am excluding the note 1. My note are currently from 1 to 999, so number like 1 could be repeated often in a number.

Here i attached the rule in part of the excel sheet at the bottom :

thanks in advance for your help!

Sub Pagination_Notes()
Dim NoteRow As Byte, RapportRow, TextePrecedent As String
NoteRow = 12
LastNoteRow = Sheet4.Range("B9999").End(xlUp).Row + 1
RapportRow = 12
LastRapportRow = Sheet1.Range("B9999").End(xlUp).Row - 1
TextePrecedent = ""
Sheet4.Range("R" & NoteRow & ":S" & LastNoteRow).Value = ""
Do While NoteRow < LastNoteRow
If InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value) Then
If InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "1") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "2") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "3") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "4") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "5") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "6") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "7") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "8") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "9") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, Sheet4.Range("C" & NoteRow).Value & "0") Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "1" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "2" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "3" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "4" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "5" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "6" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "7" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "8" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "9" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
ElseIf InStr(Sheet1.Range("AA" & RapportRow).Value, "0" & Sheet4.Range("C" & NoteRow).Value) Then
Bonne_Note = False
Else
Bonne_Note = True
End If
If Bonne_Note = True Then
If TextePrecedent <> Empty Then
Sheet4.Range("R" & NoteRow).Value = TextePrecedent & ", " & Sheet1.Range("AE" & RapportRow).Value
Else
Sheet4.Range("R" & NoteRow).Value = TextePrecedent & Sheet1.Range("AE" & RapportRow).Value
End If
TextePrecedent = Sheet4.Range("R" & NoteRow).Value
End If
RapportRow = RapportRow + 1
Else
RapportRow = RapportRow + 1
If RapportRow = LastRapportRow Then
NoteRow = NoteRow + 1
RapportRow = 12
TextePrecedent = ""
End If
End If
Loop
End Sub

EXCEL SHEET1
HALL D'ENTRÉEFAPFC2202BAXAA1,2,17,18
DANS PANNEAUBAT2X 12V4A (2019)BAAA19

EXCEL SHEET4
MP1DDOC4Aucun exemplaire du rapport d'inspection et de mise à l'essais de l'année précédente ne se trouve sur place. (Selon ULC-S536-04)DéficienceR COLUMN WHERE THE PAGE IS SHOWING
MP16ODISJ1Ce disjoncteur n'est pas verrouilllé, ni identifié rouge.ObservationR COLUMN
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,215,709
Messages
6,126,383
Members
449,311
Latest member
accessbob

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