Find multiple entries

Pinkster69

New Member
Joined
Jun 19, 2012
Messages
48
Hi Guys,

I am looking for VBA code to search for multiple entries and if those multiple entries are "True" then the code will pass the Answer in a Textbox as "Hired" or "Available"
Basically I am trying to develop a little program for Hat Hire whereby if I enter the Date of when the customer wants to hire a Hat and the SKU Number of the Hat itself the code will check to see if the hat is available on that date by passing the number "1" as true or false etc and display in a Textbox as "Hired" or "Available".
With the Help of one of MrExcel's Gurus I found success in doing this but i was wondering is it possible to code whereby we can check the following 4 days from the Date entered when the customer wants to hire the hat and if those days have not got the number "1" in the cells for those 5 days then the Textbox would display "Available" otherwise "Hired" etc.

I have attached a sample code etc to give you a better idea of what I have done so far. On the Form itself when you Press the HiredCheck Command Button you are checking to see if the Hat is Hired or not Hired, When you Press the SetHiredFlag Command Button you are entering a number "1" in the relevant cell corresponding to the Date & SKU Number

Hope you can help

regards

Derek

'--------------------------------------------------------
'--------------------------------------------------------Const DataSheet = "Data" ' Sheet with dataConst HatDates = "B17:E17" ' Address of datesConst HatSKUs = "A18:A21" ' Address of SKUsConst FLAGGEDTEXT = "Hired" ' Text to displayConst FLAG = 1 ' flag'--------------------------------------------------------'--------------------------------------------------------Private Sub SetFlag() ' Set flag in table On Local Error GoTo errors With Sheets(DataSheet) Set DateFound = .Range(HatDates).Find(what:=TextBox1.Value) Set SKUFound = .Range(HatSKUs).Find(what:=TextBox2.Value) .Cells(SKUFound.Row, DateFound.Column) = FLAG End With Exit Suberrors: MsgBox "Error: " & Err.DescriptionEnd Sub'--------------------------------------------------------'--------------------------------------------------------Private Sub GetFlag() ' display "Hired" if flagged On Local Error GoTo errors With Sheets(DataSheet) Me.TextBox3 = "" Set DateFound = .Range(HatDates).Find(what:=TextBox1.Value) Set SKUFound = .Range(HatSKUs).Find(what:=TextBox2.Value) If .Cells(SKUFound.Row, DateFound.Column) = FLAG Then Me.TextBox3 = FLAGGEDTEXT End With Exit Suberrors: MsgBox "Error: " & Err.DescriptionEnd Sub'--------------------------------------------------------'--------------------------------------------------------Private Sub HiredCheck_Click() GetFlagEnd SubPrivate Sub LBDates_Click() Me.TextBox1 = Me.LBDates.ValueEnd SubPrivate Sub LBSKUs_Click() Me.TextBox2 = Me.LBSKUs.ValueEnd SubPrivate Sub SetHiredFlag_Click() SetFlagEnd SubPrivate Sub UserForm_Initialize() Me.LBDates.Clear Me.LBSKUs.Clear For Each cCell In Range("HatDates").Cells Me.LBDates.AddItem cCell Next cCell For Each cCell In Range("HatSKUs").Cells Me.LBSKUs.AddItem cCell Next cCell </pre>
End Sub
 
Last edited:

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
HI guys, sorry but I am having problems attaching my code to my question! Cant figure out how you attach my workbook too so as to give you a better idea of what i am talking about!

Any suggestions please let me know or please look up last post with Title "Enter date and Number to find the result"

regards

Derek
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top