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: 276
Default Simplify code to lower file size. Possible ?

The code below is part of a TimeSheet i have set up.
The code below is to prevent an overlap in job finish/start times, unless
"V17".value is selected.

Is there a way i can simplify the code to be more efficiently written?
I am trying to reduce th size of the file.

((Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Range("C8") = "" Then Exit Sub
If Range("C11") = "" Then Exit Sub
If Range("C11").Value < Range("C8").Value And Range("C9").Value <
Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", , "
....."
Range("C11").ClearContents
Range("C11").Select
End If
If Range("C15") < "" And Range("C15") < Range("C12") And Range("C11").Value
< Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", ,
"...."
Range("C15").ClearContents
Range("C15").Select
End If
If Range("F8") = "" Then Exit Sub
If Range("F11") = "" Then Exit Sub
If Range("F11").Value < Range("F8").Value And Range("F9").Value <
Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", ,
"...."
Range("F11").ClearContents
Range("F11").Select
End If
If Range("F15") < "" And Range("F15") < Range("F12") And Range("F11").Value
< Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", , "
....."
Range("F15").ClearContents
Range("F15").Select
End If
If Range("I8") = "" Then Exit Sub
If Range("I11") = "" Then Exit Sub
If Range("I11").Value < Range("I8").Value And Range("I9").Value <
Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", ,
"...."
Range("I11").ClearContents
Range("I11").Select
End If
If Range("I15") < "" And Range("I15") < Range("I12") And Range("I11").Value
< Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", ,
"...."
Range("I15").ClearContents
Range("I15").Select
End If
If Range("L8") = "" Then Exit Sub
If Range("L11") = "" Then Exit Sub
If Range("L11").Value < Range("L8").Value And Range("Ll9").Value <
Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", ,
"...."
Range("L11").ClearContents
Range("L11").Select
End If
If Range("L15") < "" And Range("L15") < Range("L12") And Range("L11").Value
< Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", ,
"...." Range("L15").ClearContents
Range("L15").Select
End If
If Range("O8") = "" Then Exit Sub
If Range("O11") = "" Then Exit Sub
If Range("O11").Value < Range("O8").Value And Range("O9").Value <
Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", , "
....."
Range("O11").ClearContents
Range("O11").Select
End If
If Range("O15") < "" And Range("O15") < Range("O12") And Range("O11").Value
< Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", , "
....."
Range("O15").ClearContents
Range("O15").Select
End If
If Range("R8") = "" Then Exit Sub
If Range("R11") = "" Then Exit Sub
If Range("R11").Value < Range("R8").Value And Range("R9").Value <
Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", , "
....."
Range("R11").ClearContents
Range("R11").Select
End If
If Range("R15") < "" And Range("R15") < Range("R12") And Range("R11").Value
< Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", ,
""
Range("R15").ClearContents
Range("R15").Select
End If
If Range("U8") = "" Then Exit Sub
If Range("U11") = "" Then Exit Sub
If Range("U11").Value < Range("U8").Value And Range("U9").Value <
Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", , "
....."
Range("U11").ClearContents
Range("U11").Select
End If
If Range("U15") < "" And Range("U15") < Range("U12") And Range("U11").Value
< Range("V17").Value Then
MsgBox "There is an overlap in the Times Entered." & vbCrLf & "The next
Start Time needs to be equal or greater than the previous Finish Time.", , "
....."
Range("U15").ClearContents
Range("U15").Select
End If
End Sub


COrey....


 
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
Can I simplify a VB code?????? hoyos Excel Discussion (Misc queries) 1 November 6th 09 09:06 PM
code to check file size everytime an Excel file is opened Kaiser[_2_] Excel Programming 2 July 30th 06 05:46 PM
Simplify this code Scott Excel Programming 2 February 8th 06 03:56 AM
File Size Code not working briank Excel Programming 11 March 2nd 05 04:45 PM
Help to simplify code. Michael Beckinsale Excel Programming 0 September 2nd 03 10:26 AM


All times are GMT +1. The time now is 06:38 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"