LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 2 Questions

Thanks Chris,

You're twigging my college excel programming days - vaguely, now I'm getting
a syntax error @ the

Private Sub_worksheet - line

I know I'm probably scfewing something up (this is why I got out of
programming)

Thanks Dom

"cht13er" wrote:

On May 2, 11:01 am, paramedic_dom
wrote:
These will probably show my ignorance but, 2 ques.

I've been asked to look at a spreadsheet and look at inhancing it. The
ques. I have to ask are these:

I want a formula to look at the prev. cell and if ther is a number in the
cell than to add 3 hrs (h:m) to an entered time and place that number in a
cell and add the number of hrs in decimal form in another cell.

Second thing is to not allow next entry (hr:m) if it is within the 3 hrs if
the above exists.

Does that make sense and/or can it be done?

Many thanks in advance,

Dom


To answer your third question first: yes, it can be done.

Let's say that the entered time is in A1. The formula to find the time
3 hours from A1 will then be in B1 and will read
=IF(ISNUMBER(A1),A1+TIME(3,,),"")
The formula in C1 will convert the time in B1 to hours:
=IF(ISNUMBER(B1),HOUR(B1)+MINUTE(B1)/60+SECOND(B1)/3600,"")

To restrict the user from entering a time within three hours of the
time above it, paste this into the appropiate sheet's code (Hit Alt
+F11 to get into the Visual Basic Editor and then doubleclick on the
sheet's name on the left panel called the Project Explorer:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Len(Target) 0 Then
If IsNumeric(Range(Target.Address).Offset(-1, 0).Value) = True And
IsNumeric(Range(Target.Address).Value) = True Then
If Target.Value - (3 / 24) < Range(Target.Address).Offset(-1,
0).Value Then
Call MsgBox("Can't enter in a time less than three hours
after the cell above.")
Range(Target.Address).ClearContents
End If
End If
End If

End Sub



HTH

Chris

 
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
Answers to questions posing more questions in a workbook sbelle1 Excel Worksheet Functions 2 August 8th 09 01:02 AM
2 Questions Richard Excel Discussion (Misc queries) 3 July 18th 09 06:12 AM
Questions??? Rosebud Excel Worksheet Functions 9 November 27th 08 12:46 AM
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
Max / IF questions G Excel Discussion (Misc queries) 1 October 12th 05 03:27 AM


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