Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validate Appointment Times?

Here's what I have:

One master spreadsheet
One data entry spreadsheet - appointments are copied to the master
spreadsheet's next available row.

My program searches through each row to see if there is an appointment
conflict before the appointment is copied. I just can't seem to get it
to work though! It works if the dates or times are equal. For example,
if there is an existing appointment for 3:30 - 4:30 and I try to add
one for 4:00 - 5:00, the program will allow it (probably because my
code and/or logic is wrong). My code is as follows:

Sub UpdateMaster()

' Macro1 Macro
' Macro recorded 12/11/2003 by 787940
'
Dim r As Integer
Dim MyRow As Integer
Dim ApptDate As Date
Dim ApptStart As Date
Dim ApptEnd As Date

MyRow = ActiveCell.Row

ApptDate = Range("D" & MyRow).Value
ApptStart = Range("E" & MyRow).Value
ApptEnd = Range("F" & MyRow).Value

'MsgBox "Apptdate: " & ApptDate & " Apptstart: " & ApptStart & "
apptdur: " & ApptDur & " apptend: " & ApptEnd
'Exit Sub

Range("A" & MyRow & ":F" & MyRow).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Master").Select

r = 2

Dim CheckApptDate, CheckApptStart, CheckApptEnd As Date

Do
'Set the variables
CheckApptDate = Range("D" & r).Value
CheckApptStart = Range("E" & r).Value
CheckApptEnd = Range("F" & r).Value

'Check the appointment date
If ApptDate = CheckApptDate Then
'Check the start time
If ApptStart = CheckApptStart Then
MsgBox "This appointment time already exists. Please
select another time."
Application.CutCopyMode = False
Range("D" & r).Select
Exit Sub
Else
If ApptStart CheckApptStart And ApptEnd
CheckApptEnd Then
MsgBox "This appointment conflicts with another
appointment. Please select another time."
Application.CutCopyMode = False
Range("D" & r).Select
Exit Sub
End If
End If
Else
'do nothing
End If

r = r + 1


Loop Until Cells(r, 256).End(xlToLeft).Column = 1 And Cells(r, 1)
= ""

Cells(r, 1).Select

ActiveSheet.Paste Link:=True
Application.CutCopyMode = False



End Sub

Thanks in advance for your help!
Shelley
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
Creating Appointment Dan Wood Excel Discussion (Misc queries) 11 April 28th 10 08:22 AM
Appointment Calendar.xlt help Ernie Lippert[_2_] Excel Discussion (Misc queries) 3 June 5th 09 02:15 AM
Linking appointment dates JayDee Excel Worksheet Functions 0 July 24th 08 05:10 PM
Appointment Card Template stewsutherland New Users to Excel 3 January 10th 05 06:13 PM
Appointment calendar in Excel Phillips Excel Programming 2 December 3rd 03 08:50 PM


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

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

About Us

"It's about Microsoft Excel"