Hi guys,
I'm very new to this and to visual basics. I have very limited experience in programming. I need some help. I created a search marco. It has a text box for the user to type in what they are looking for from a crazy long list located on another sheet and a command button to begin the search. Everything works fines except I cannot press the Enter key to get it to work. Is there any way around this? I only added the code to the command box.
Here is the code I made after many many many months:
Private Sub CommandButton1_Click()
Dim FoundCell As Range
Dim LastCell As Range
Dim FirstAddr As String
Dim sht As Worksheet
Dim Vu
Dim intS As Integer
Dim rngC As Range
Dim strToFind As String, FirstAddress As String
Dim wSht As Worksheet
Dim myshape As Shape
Sheets("Search Results").Select
Range("a13:F26600").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.clearcontents
Selection.Interior.ColorIndex = 2
For Each myshape In ActiveSheet.Shapes
object.
If myshape.Type = 17 Then myshape.Delete
Next myshape
Range("B13").Select
On Error Resume Next
Vu = SearchBox.Value
Application.ScreenUpdating = False
intS = 13
'This step assumes that you have a worksheet named
'Search Results.
Set sht = Worksheets("Search Results")
strToFind = Vu
'Change this range to suit your own needs.
With Sheets("ibccodes").Range("A1:F8000")
Set rngC = .Find(What:=strToFind, LookAt:=xlPart)
If Not rngC Is Nothing Then
FirstAddress = rngC.Address
Do
Range("D13").Select
rngC.EntireRow.Copy sht.Cells(intS, 1)
intS = intS + 2
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address <> FirstAddress
End If
End With
If Vu = "" Then
MsgBox "No Value Entered"
Exit Sub
End If
Sheets("Search Results").Select
End Sub
Any help is appreciated.
I'm very new to this and to visual basics. I have very limited experience in programming. I need some help. I created a search marco. It has a text box for the user to type in what they are looking for from a crazy long list located on another sheet and a command button to begin the search. Everything works fines except I cannot press the Enter key to get it to work. Is there any way around this? I only added the code to the command box.
Here is the code I made after many many many months:
Private Sub CommandButton1_Click()
Dim FoundCell As Range
Dim LastCell As Range
Dim FirstAddr As String
Dim sht As Worksheet
Dim Vu
Dim intS As Integer
Dim rngC As Range
Dim strToFind As String, FirstAddress As String
Dim wSht As Worksheet
Dim myshape As Shape
Sheets("Search Results").Select
Range("a13:F26600").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.clearcontents
Selection.Interior.ColorIndex = 2
For Each myshape In ActiveSheet.Shapes
object.
If myshape.Type = 17 Then myshape.Delete
Next myshape
Range("B13").Select
On Error Resume Next
Vu = SearchBox.Value
Application.ScreenUpdating = False
intS = 13
'This step assumes that you have a worksheet named
'Search Results.
Set sht = Worksheets("Search Results")
strToFind = Vu
'Change this range to suit your own needs.
With Sheets("ibccodes").Range("A1:F8000")
Set rngC = .Find(What:=strToFind, LookAt:=xlPart)
If Not rngC Is Nothing Then
FirstAddress = rngC.Address
Do
Range("D13").Select
rngC.EntireRow.Copy sht.Cells(intS, 1)
intS = intS + 2
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address <> FirstAddress
End If
End With
If Vu = "" Then
MsgBox "No Value Entered"
Exit Sub
End If
Sheets("Search Results").Select
End Sub
Any help is appreciated.