arjan kooger
New Member
- Joined
- Feb 18, 2024
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Good afternoon,
I have a bed list with names in column B and bed numbers in column L ( like 10T, 10B, 11T, 11B etc.).
i use a macro that works pretty well, but it shows only the first names in a message box (in Another sheet) if there are duplicates.
Can anyone help me with a macro what will show both names in the same bed in a message box?
Thanks in advance!
A B L
Sub Test()
ThisWorkbook.Sheets("POB").Activate
Set R = Range("L4", Range("L" & Rows.Count).End(xlUp))
For Each c In R
D = Cells(c.Row, c.Column - 10).Value
If WorksheetFunction.CountIf(R, c) > 1 Then If InStr(1, s, c) = 0 Then s = s & c & "," & " - " & D & vbCr
Next
ThisWorkbook.Sheets("All").Activate
MsgBox IIf(s <> "", "Duplicate beds in the List" & vbLf & Mid(s, 1), "No duplicates")
End Sub
I have a bed list with names in column B and bed numbers in column L ( like 10T, 10B, 11T, 11B etc.).
i use a macro that works pretty well, but it shows only the first names in a message box (in Another sheet) if there are duplicates.
Can anyone help me with a macro what will show both names in the same bed in a message box?
Thanks in advance!
A B L
1 | Adamson (N) | 17T | |||||||||
2 | Aquilina (N) | 16T | |||||||||
3 | Bacic (N) | 34T | |||||||||
4 | Buruiana (N) | 11T | |||||||||
5 | Butter | 50B | |||||||||
6 | Ciparis | 57B | |||||||||
7 | Devic (N) | 09T | |||||||||
8 | Gray | 11T | |||||||||
9 | Halliday (N) | 51B | |||||||||
10 | Hoeksema (N) | 10T | |||||||||
11 | Hoekstra | 40T | |||||||||
12 | Jozic | 13T | |||||||||
13 | Kristkalns | 41B | |||||||||
14 | Martin | 13T | |||||||||
15 | Mifsud | 56B | |||||||||
16 | Mitrofanovs | 34T | |||||||||
17 | Muscat | 09T | |||||||||
18 | Pauli | 12T | |||||||||
19 | Penava | 42B | |||||||||
20 | Rancans | 17T | |||||||||
21 | Rocha | 16T | |||||||||
22 | Sinenkij (N) | 13T | |||||||||
23 | Srac (N) | 15T |
Sub Test()
ThisWorkbook.Sheets("POB").Activate
Set R = Range("L4", Range("L" & Rows.Count).End(xlUp))
For Each c In R
D = Cells(c.Row, c.Column - 10).Value
If WorksheetFunction.CountIf(R, c) > 1 Then If InStr(1, s, c) = 0 Then s = s & c & "," & " - " & D & vbCr
Next
ThisWorkbook.Sheets("All").Activate
MsgBox IIf(s <> "", "Duplicate beds in the List" & vbLf & Mid(s, 1), "No duplicates")
End Sub