Looping and searching

G

Guest

I have a userform in which the user is to enter two dates, a start date and
an end date. My code then searches a spreadsheet. First I find the cell that
contains the text "Date". I then want to the adress for start date. The code
is:

Do Until IsEmpty(rng(1).Offset(i, 0)) = True Or rng(1).Offset(i, 0).text =
strStartDatumArray(1) = True
i = i + 1
Loop

The problem with the code is that if the startdate is not found it takes the
address of the cell that is one cell below the last cell that contains any
values. Does anyone know how to fix this? I also would like fix the code so
if the user enters a date that is a saturday or a sunday my program will
generate a message box. Is this possible? please help me if you can! Thanks!
 
G

Guest

if Weekday(cdate(strStartDatumArray(1)),vbMonday) > 5 then
msgbox "Please Don't Enter a Weekend"
exit sub
end if
Do Until IsEmpty(rng(1).Offset(i, 0)) = True Or (rng(1).Offset(i, 0).text =
strStartDatumArray(1)) = True
i = i + 1
Loop
If not isempty(rng(1).Offset(i)) then


else
msgbox "Not found"
End if
 

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