Hi There
This is my first post (And VBA newby)
I found this code (did a little modifying) in this forum for a search in excel, works fine but can you help me on this one:
How can show a message to the user when nothing is found?
I added MsgBox "Niets gevonden" (Nothing found in English) , but this show on every search. Where do I place within this code?
This is my first post (And VBA newby)
I found this code (did a little modifying) in this forum for a search in excel, works fine but can you help me on this one:
How can show a message to the user when nothing is found?
I added MsgBox "Niets gevonden" (Nothing found in English) , but this show on every search. Where do I place within this code?
Code:
[COLOR=#000000][FONT=-webkit-standard]Sub myfind()[/FONT][/COLOR][COLOR=#000000][FONT=-webkit-standard] Dim Message, Title, Default, SearchString[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Message = "Zoeken op gedetineerde!" ' Set prompt.[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Title = "Toets een naam in" ' Set title.[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Default = "B.Oef" ' Set default.[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] ' Display message, title, and default value.[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] SearchString = InputBox(Message, Title, Default)[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard]
[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] 'SearchString = "Rob"[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Set S = Sheets.Application[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] For Each S In Application.Sheets[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] With S.Range("B1:B400")[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Set F = .Find(SearchString, MatchCase:=False, LookAt:=xlPart, [/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard]LookIn:=xlValues)[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] If F Is Nothing Then[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Else[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Location = F.Address[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] S.Select[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Range(Location).Select[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Exit For[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] End If[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] End With[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] Next S[/FONT][/COLOR]
[COLOR=#000000][FONT=-webkit-standard] End Sub[/FONT][/COLOR]