Solved

Populate a user form with a formula to calculate units per hr

Posted on 2015-02-09
7
51 Views
Last Modified: 2015-02-10
From the time sheet form button, can the units per hour be calculated
StlFunction-Analisys-2015-v1f.xlsm
0
Comment
Question by:bjfulkerson
  • 3
  • 3
7 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40600246
Don't understand the question.
0
 
LVL 10

Accepted Solution

by:
broro183 earned 500 total points
ID: 40600459
hi,

Try adding the following code into the code behind the TimeSheetEntry Form module. This seems to hold up okay under some light testing.


Private Sub TxtTime_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Call CalcAndUpdateUPH_tbx
End Sub

Private Sub TxtUnits_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Call CalcAndUpdateUPH_tbx
End Sub

Sub CalcAndUpdateUPH_tbx()
With Me
        'test that both fields are populated.
        If Len(.TxtTime.Value) * Len(.TxtUnits.Value) Then
            'validate that the entries are numeric.
            If IsNumeric(.TxtTime.Value) And IsNumeric(.TxtUnits.Value) Then
                .TxtUPH.Value = .TxtUnits.Value / .TxtTime.Value
            End If
        End If
    End With
End Sub

Open in new window


hth
Rob
0
 

Author Comment

by:bjfulkerson
ID: 40600466
Rob,
When you say behind, what does that mean?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Closing Comment

by:bjfulkerson
ID: 40600471
I added it to the top of the TimesheetEntry and it worked great!  Thanks for adding the explanations too!
0
 
LVL 10

Expert Comment

by:broro183
ID: 40600472
Sorry, I didn't word that very well.

It may just be my settings but when I double (left) click on the TimeSheetEntry item in the Forms folder within the Project Pane of the VBE, the result is that the Userform appears (on the right for me). To see the code relating to the Userform, I press [F7] or right click on on the item in the lefthand pane & choose "view code". This then shows the code relating to the userform eg "Private Sub UserForm_Initialize()" or "Private Sub Calendar1_Click()".

I consider this code as being "behind" the userform.

Rob
0
 

Author Comment

by:bjfulkerson
ID: 40600473
Got it . Thanks
0
 
LVL 10

Expert Comment

by:broro183
ID: 40600480
Awesome, I'm pleased I could help :-)

Now that it is a calculated field, I suggest changing the appearance of the textbox so that users can easily recognise that they don't need to populate it (eg "grey it out" by changing the backcolour to something like &H80000000&.
Or, if you want to get more complicated, you could allow users to enter values into any two of the three fields & then have the code calculate whichever one is the remaining empty field.

Rob
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now