Search column for date

dualhcsniatpac

Board Regular
Joined
Feb 18, 2009
Messages
126
Im sorry if this is a repeat. I have searched and could not come up with anything close to adapt to my scenario.

I have a form that contains daily volumes. These will be entered in 1 time per day. What I would like, to prevent duplicate entries, is to (upon user submitting the volumes) first have the vba code check to see if there is already a date.

User submits volume data --> code checks to see if volume data is already entered in for that day.

If there is no date, then just enter the data like normal. If there is, I would like a textbox saying that there is already volume data for that day, would you like to overwrite or save old data.

I think I might be able to figure it out but I do not know how to dynamically search a row for something.

Thanks in advance.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
This code searches Column A (well a range) for Todays Date.

Code:
Sub FindDate()

On Error GoTo errorhandler:

Dim rng As Range
Set rng = Range("A1:A100")

today = Date


X = rng.Find(today)
MsgBox "Volume has already been added for day"
Exit Sub

errorhandler:

MsgBox "Your code here"


End Sub
 
Upvote 0

Forum statistics

Threads
1,222,441
Messages
6,166,054
Members
452,010
Latest member
triangle3

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