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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

DiscoPistol

Active Member
Joined
Jun 6, 2006
Messages
261
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,191,689
Messages
5,988,032
Members
440,125
Latest member
vincentchu2369

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
Top