I have a database in Excel 2010 listing different measuring equipment. Each piece has an ID and some other stuff is known.
Each entry line looks like this:
ID … … Need for a pop-up?
1 … … NO
2 … … YES
3 … … NO
4 … … NO
and so on.
Out of information like availability or functionality, I have created a formula that sums up these information and gives the answer "YES" or "NO" to the question:"Need for a pop-up warning?" So whenever someone wants to lend a piece of equipment that might not work/be available, the user should be warned with a pop-up saying something like: "Warning for: Device with ID 111. This gauge might be defect/not available."
I already have some code that will give me a pop-up message every time the question:"Need for a pop-up" is answered with "YES" but I fail to align the ID of the affected piece in the text of the pop-up.
Sub POP_UP_if_defect()
'In Cells N6:N500 are the answers "YES" or "NO" listed
For Each Cell In Sheets ("Sheet X").Range("N6:N500")
If Cell.Value = "YES" Then
MsgBox "Warning: This device might be defect/not available!"
End If
Next
End Sub
Thank you in advance for any help on this one!
When cell
contains "YES", you have to get the id from Column "A" of that row. Try something like this:
With Sheets("Sheet X")
For Each cell In .Range("N6:N500")
If cell.Value = "YES" Then
Dim id
id = .Cells(cell.row, 1)
MsgBox "Warning: device " & id & " might be defect/not available!"
End If
Next cell
End With
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.