Pinaceous
Well-known Member
- Joined
- Jun 11, 2014
- Messages
- 1,113
- Office Version
- 365
- Platform
- Windows
Hi All,
I'm trying to provide a sub where if it finds a specific text (for example "BookOne.xlsx") in Range("B:B") Then it will provide a MsgBox "Positive result" for all of its entries.
Likewise, if it does not find the text I'd like it to provide only one MsgBox "Negative result" pop-up and not a pop-up for every entry.
Please lend a hand.
Thank you!
pinaceous
I'm trying to provide a sub where if it finds a specific text (for example "BookOne.xlsx") in Range("B:B") Then it will provide a MsgBox "Positive result" for all of its entries.
Likewise, if it does not find the text I'd like it to provide only one MsgBox "Negative result" pop-up and not a pop-up for every entry.
VBA Code:
Sub string_validation()
Dim cel As Range
For Each cel In Range("B:B")
If cel.Value = "BookOne.xlsx" Then
MsgBox "Positive result"
Workbooks.Open cel.Offset(, 1)
Else
MsgBox "Negative result"
End If
Next cel
End Sub
Please lend a hand.
Thank you!
pinaceous