Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2007

Tip: Looking for answers? Try searching our database.

Formula help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chad - 05 Nov 2007 15:51 GMT
Hello, I have a form in my excel workbook that is brought up by a buttons on
click event. On this form I have 5 text boxes.
1) txtMinutesWorked
2) txtRunMinutes
3) txtDelayMinutes
4) txtDelayHours
5) txtDelayInDecimal

Here is an example calculation of what im looking for the form to calculate.
If I enter 480 into “txtMinutesWorked” and I enter 240 into “txtRunMinutes”
then “txtDelayMinutes” would calculate a number 240 and “txtDelayHours” would
calculate a number 4h 0m and “txtDelayInDecimal” would calculate 4.0. What
VBA would I put in what boxes to get the numbers I need calculated? I have
this working on a worksheet but I wanted to do it in a popup in VB..

Thanks!

Signature

Newbies need extra loven.........

te_butts - 06 Nov 2007 18:59 GMT
This will get you going.

Now, just so you know, this doesn't recalculate for minutes more then 60,
and convert it to hours, then remaining minutes.

Just play with the numbers in your two input textboxes and you will see what
i mean.

--------------------------------------------
Private Sub txtRunMinutes_Change()
           Dim sHours As String
           sHours = (Me.txtMinutesWorked.Text - Me.txtRunMinutes.Text) / 60
           
           Dim sHours2 As String
           sHours2 = FormatNumber(Me.txtMinutesWorked.Text, 0)

           Dim sMinutes As String
           sMinutes = Me.txtMinutesWorked.Text
           
           Dim sMinutes2 As String
           sMinutes2 = FormatNumber(Me.txtRunMinutes.Text, 0)

           Dim sTotalMinutes As String
           sTotalMinutes = sHours2 - sMinutes2
           Me.txtDelayMinutes.Text = sTotalMinutes

           Dim sTotalHours As String
           sTotalHours = FormatNumber(sHours, 0) & "h "
           
           Dim sTotalMinutes2 As String
           sTotalMinutes2 = sTotalMinutes -
FormatNumber(Me.txtRunMinutes.Text, 0)

           Dim sLessMinutes As String
           sLessMinutes = sTotalHours & sTotalMinutes2 & "m"
           Me.txtDelayHours.Text = sLessMinutes

           Me.txtDelayInDecimal.Text = FormatNumber(sHours, 1)
End Sub

------------------------------------------------

There is always a better, more streamlined way of doing it, but i just blew
it out to give you a quick answer.

Hope this helps.

> Hello, I have a form in my excel workbook that is brought up by a buttons on
> click event. On this form I have 5 text boxes.
[quoted text clipped - 12 lines]
>
> Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.