Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Formula help
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! -- Newbies need extra loven......... |
#2
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Formula help
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. "Chad" wrote: 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! -- Newbies need extra loven......... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|