![]() |
Looping and searching
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! |
Looping and searching
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 -- Regards, Tom Ogilvy "Bloomberg" wrote: 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! |
All times are GMT +1. The time now is 12:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com