Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not Looping Roger Excel Discussion (Misc queries) 0 February 26th 08 05:18 PM
Searching, matching then searching another list based on the match A.S. Excel Discussion (Misc queries) 1 December 13th 06 05:08 AM
Help with Looping I think Mike Excel Programming 2 April 25th 06 04:23 PM
Looping Buffyslay Excel Programming 1 February 1st 06 05:57 PM
Looping René Excel Programming 6 May 28th 04 02:14 PM


All times are GMT +1. The time now is 05:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"