AndrewMB
Board Regular
- Joined
- Feb 3, 2008
- Messages
- 75
Hello again,
I have a bit of VBA code setup, that allows a user to enter either a part name, bin number, or order number and upon clicking a button, any data relating to that part name, number or order number will be returned.
To do this, (and this may not have been the best way to do it, at all) I have used the autofilter function and have set the filter criteria by whatever variable the user types in.
The sheet works exactly how I want it to. It returns all the data there is, relating to the variable typed in.
The only problem I have, is if the user clicks the button without typing in a part name, or bin number etc... pressing it with the variable field empty, all data is returned.
Here is the code:
Dim Inp As String
Inp = Range("C5")
Sheets("SCRIPT (DO NOT MODIFY)").Select
Selection.AutoFilter Field:=2, Criteria1:=Inp
Range("A2:A54").Select
Selection.Copy
Sheets("FRONTEND").Select
Range("G25").Select
ActiveSheet.Paste
Above is just a snapshot of the bits that matter. I would like the sheet to not return any data if the variable entered does not match any criteria listed within the autofilter. As a bonus I would like it to state, "No such data" or something like that.... rather than just staying blank.
I have a bit of VBA code setup, that allows a user to enter either a part name, bin number, or order number and upon clicking a button, any data relating to that part name, number or order number will be returned.
To do this, (and this may not have been the best way to do it, at all) I have used the autofilter function and have set the filter criteria by whatever variable the user types in.
The sheet works exactly how I want it to. It returns all the data there is, relating to the variable typed in.
The only problem I have, is if the user clicks the button without typing in a part name, or bin number etc... pressing it with the variable field empty, all data is returned.
Here is the code:
Dim Inp As String
Inp = Range("C5")
Sheets("SCRIPT (DO NOT MODIFY)").Select
Selection.AutoFilter Field:=2, Criteria1:=Inp
Range("A2:A54").Select
Selection.Copy
Sheets("FRONTEND").Select
Range("G25").Select
ActiveSheet.Paste
Above is just a snapshot of the bits that matter. I would like the sheet to not return any data if the variable entered does not match any criteria listed within the autofilter. As a bonus I would like it to state, "No such data" or something like that.... rather than just staying blank.