frostflower11
New Member
- Joined
- Jun 19, 2016
- Messages
- 3
I have some bugs in this code that I am having trouble fixing.
The StateSearch sub is supposed to get a state name from the user, call the FindState sub, then display a message if the state is listed in the workbook. The FindState sub searches for the name given by the user.
This is the code I have so far:
Sub StateSearch()
Dim state As String
state = InputBox("Enter a state you'd like to search for.", "State search")
Call FindState(state As String)
MsgBox "State was " & isFound, vbInformation
End Sub
Sub FindState(state As String)
Dim isFound As Boolean
For Each ws In ActiveWorkbook
If ws.Name = state Then
isFound = True
Exit For
Else
isFound = False
End If
Next
End Sub
The StateSearch sub is supposed to get a state name from the user, call the FindState sub, then display a message if the state is listed in the workbook. The FindState sub searches for the name given by the user.
This is the code I have so far:
Sub StateSearch()
Dim state As String
state = InputBox("Enter a state you'd like to search for.", "State search")
Call FindState(state As String)
MsgBox "State was " & isFound, vbInformation
End Sub
Sub FindState(state As String)
Dim isFound As Boolean
For Each ws In ActiveWorkbook
If ws.Name = state Then
isFound = True
Exit For
Else
isFound = False
End If
Next
End Sub