VBA: Look-Up Cell Date From User Input Box and return ALL matches

M

Mcasteel

I'm looking for a look-up solution for a worksheet.

My worksheet column 68 contains dates. I need to figure out how t
code the following scenario:

The end user enters a date into an input box:
dtReportDate = (Date:=strReportDate).

I want to display ALL matching dates in another worksheet("To Do List"
to create a report. Im assuming I will need some kind of a Loo
Statement or For Each statement.

Can anyone help me out?

Thanks
 
D

Dave Peterson

Maybe some ideas (untested and may contain typos!):

dim dtReportDate as date
dim myCell as range
dim myRng as range
dim oRow as long

'''
if isdate(strreportdate) then
dtreportdate =cdate(strReportdate)
else
msgbox "not a date"
exit sub
end if

'''
with worksheets("sheet1withdates")
set myrng = .range(.cells(1,68),.cells(.rows.count,68).end(xlup))
end with

orow = 0
for each mycell in myrng.cells
if mycell.value = dtreportdate then
orow = orow + 1
with worksheets("to do list").cells(orow,"A")
.value = mycell.value
.offset(0,1).value = mycell.offset(0,3).value 'whatever???
end with
next mycell

Just a note about your previous posts compared to this one.

When the question is narrow, you have a much better chance of getting a
response. Isolating just one little portion is a lot less intimidating for most
responders (well, at least for me!).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top