Hello All,
I was hoping somebody would be able to take a look at my spreadsheet and help me out with a problem I was having. I have tried to make the sheet so that I would have a searchbox in Sheet 1, that would look at the data in Sheet two and Return the results in Sheet 3.
The Search would look at Column A in Sheet 2 and Return all Instances of that Result in Sheet 3 (Including all other data in the Row).
If anyone was able to tell me the code that would help, I am very new to
VB coding and had been trying to tinker with the code that I found on a website
Code:
Sub CommandButton1_Click()
'Standard Sheet Module code, like: Sheet1.
Dim ifFound
Dim Message$, Title$, Default$, myCode$
Message = "Enter Workstation/Laptop Number:" ' Set prompt.
Title = "Workstation Search" ' Set title.
Default = "" ' Set default.
' Display message, title, and default value.
myCode = InputBox(Message, Title, Default)
MsgBox "Var1: value is " & myCode
ifFound = False
Application.ScreenUpdating = False
ifFound = True
'Check data sheet for data wanted!
Worksheets("Sheet2").Select
For Each r In Worksheets("Sheet2").UsedRange.Columns
n = r.Column
If Worksheets("Sheet2").Cells(1, n) = myCode Then
MsgBox "Var2: value is " & ifFound
ifFound = True
'Copy the found data from the starting row = myStart to
'the ending row = myFinish for the Found Date [myDate]
'to Sheet2 in column "C" change as needed!
'Start data import just below any entery in this column!
Worksheets("Sheet2").Range(Cells(2, n), Cells(4, n)).Copy _
Destination:=Worksheets("Sheet3").Range("C65536").End(xlUp).Offset(1, 0)
Else
End If
Next r
If ifFound = False Then MsgBox "Not Found!"
Worksheets("Sheet3").Select
Application.CutCopyMode = True
Application.ScreenUpdating = True
End Sub
What I had managed to do so far was prove that the Data I entered was being stored in the variable but had not really got any further than that.