Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not Looping | Excel Discussion (Misc queries) | |||
Searching, matching then searching another list based on the match | Excel Discussion (Misc queries) | |||
Help with Looping I think | Excel Programming | |||
Looping | Excel Programming | |||
Looping | Excel Programming |