LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trouble with lots of IF THEN statements???


Hi all below is some code for finding a worksheet then a particular
range then check whether cells are empty or mot based on the values in
comboboxes on a userform, the text coloured in blue i have just added
(in order to check offsets according to which name appeared in
ComboBox2) prior to that the lines i have stetted out worked perfect
for finding the correct line and checking the offset's for values, now
the code runs through without recognising the persons name so not
checking the offsets.......Anyone know how to fix this?, i'm sure its
the way i have used the IF THEN statements!

Regards,
Simon

Public Sub FindSlot()
Dim strFirst As Integer
Dim rng As Range
Dim w, vf, t, s As Variant
Dim r As Range
Dim mycell
Application.EnableEvents = False
w = UserForm2.ComboBox3.Value
vf = UserForm2.ListBox1.Value
s = UserForm2.ComboBox2.Value
Worksheets(w).Visible = True
Worksheets(w).Select
t = UserForm2.ComboBox1.Value
If t = "Tuesday" Then
Set r = Worksheets(w).Range("A4:A46")
ElseIf t = "Wednesday" Then
Set r = Worksheets(w).Range("A49:A94")
ElseIf t = "Thursday" Then
Set r = Worksheets(w).Range("A97:A142")
ElseIf t = "Friday" Then
Set r = Worksheets(w).Range("A145:A190")
ElseIf t = "Saturday" Then
Set r = Worksheets(w).Range("A193:A238")
End If
'On Error GoTo cls
Application.EnableEvents = False

For Each mycell In r
If mycell.Text = UserForm2.ListBox1.Text Then
mycell.Select
'UserForm2.Hide

If s = "Lauren" Then
If mycell.Offset(0, 1) < "" And mycell.Offset(0, 3) < "" Then
MsgBox "Please Choose New Time, Day or Week... " & mycell.Value & " Is
Taken!", _
vbOKOnly, "Time Slot Taken"
ElseIf s = "Emma" Then
If mycell.Offset(0, 5) < "" And mycell.Offset(0, 7) < "" Then
MsgBox "Please Choose New Time, Day or Week... " & mycell.Value & " Is
Taken!", _
vbOKOnly, "Time Slot Taken"
ElseIf s = "Cheryl" Then
If mycell.Offset(0, 9) < "" And mycell.Offset(0, 11) < "" Then
MsgBox "Please Choose New Time, Day or Week... " & mycell.Value & " Is
Taken!", _
vbOKOnly, "Time Slot Taken"
'If mycell.Offset(0, 1) < "" And mycell.Offset(0, 3) < "" And
mycell.Offset(0, 5) < "" And mycell.Offset(0, 7) < "" And
mycell.Offset(0, 9) < "" And mycell.Offset(0, 11) < "" Then

'MsgBox "Please Choose New Time, Day or Week... " & mycell.Value & " Is
Taken!", _
'vbOKOnly, "Time Slot Taken"
UserForm2.Show
Exit Sub
ElseIf mycell.Offset(0, 1) = "" Or mycell.Offset(0, 3) = "" Or
mycell.Offset(0, 5) = "" Or mycell.Offset(0, 7) = "" Or
mycell.Offset(0, 9) = "" Or mycell.Offset(0, 11) = "" Then
If MsgBox("Chosen Time Has An Empty Slot" & Chr(13) & "Click Yes to
Make Booking or Click No To Exit", vbYesNo, "Make A Booking?") = vbYes
Then
Unload UserForm2
UserForm1.Show

End If
End If
End If
End If
End If
End If

Next

Worksheets("Week Selection").Visible = True
Worksheets(w).Visible = False
cls:
Application.EnableEvents = True
Unload UserForm2
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=557623

 
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
3 lots of information to be put on a chart EmJay80 Charts and Charting in Excel 2 October 2nd 09 08:46 AM
MS Query uses lots of CPU Bamajohn Excel Discussion (Misc queries) 0 January 19th 06 11:46 PM
lots of data lwm11 Excel Discussion (Misc queries) 2 May 13th 05 07:31 PM
change lots of formulae all at once - how? simon Excel Programming 3 March 16th 05 07:04 PM
Lots of Frustration - Lots of Arrays, Dynamic Ranges Don't Work, Help With Options Karl Burrows Excel Programming 4 April 17th 04 12:48 PM


All times are GMT +1. The time now is 10:30 AM.

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"