Solved

Managing a users response

Posted on 2013-10-29
8
161 Views
Last Modified: 2013-10-29
Folks,
In my workbook are many worksheets that show a function or formula for the user. I allow them to change the data so they can see the impact of their data change. The worksheet will be protected to only allow changes to the pieces.

In the attached worksheet, as an example, I have a command button "Enter Answer". The purpose of this is for the user to enter in the name of the most productive employee based upon pieces per hour. If the answer is correct then there will be a response "Correct answer - great job!". If not then the name entered will appear with a response "XXXXXX is not the most productive employee. Try again!"

Since the user can change the number of pieces the most productive employee can also change.

I know how to capture the user  response in VBA. I know that I need to find the Max value from D4:D9. I know I need to match the Max value to the name. I know that if the names do not agree then the user has not entered in the correct name.

Except for capturing the user response I do not know how to code the rest.
MostProductive.xlsm
0
Comment
Question by:Frank Freese
  • 5
  • 2
8 Comments
 

Author Comment

by:Frank Freese
ID: 39609124
Let me break this question down into several questions to begin with since I can see that happening. Here's code that I have tried just to get the Max from a range:
Private Sub cmdIdentifyMostProductive_Click()
Dim MaxRange As Range
Dim MaxAnswer As Double
Set MaxRange = Worksheets("Production Per Hour").Range("D4:D9")
MaxAnswer = Application.WorksheetFunction.Max(MaxRange)
End Sub

Open in new window


What I am trying to do is simply get the Max value from the range D4:D9 and assign it to MaxAnswer. This code only returns a zero. So if you all do not mind, let's start here first. Once this has been resolved I'll open the next question.
0
 
LVL 50

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
ID: 39609127
Hi,

as a formula
=INDEX(A4:A9,MATCH(MAX(D4:D9),D4:D9,0))

Open in new window

in VBA
Result = WorksheetFunction.Index(Range("A4:A9"), WorksheetFunction.Match(WorksheetFunction.Max(Range("D4:D9")), Range("D4:D9"), 0))

Open in new window

and then compare the result with the response
if Result = Response then
    MsgBox "You're right"
Else
    MsgBox " You're wrong. Please retry!"
End If

Open in new window


Regards
0
 

Author Comment

by:Frank Freese
ID: 39609170
OK...I got the number I was looking for so I'll close this question and move onto something else.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 18

Accepted Solution

by:
Steven Harris earned 250 total points
ID: 39609190
I came up with the same as Rgonzo:

Private Sub cmdIdentifyMostProductive_Click()
    Dim mName As String
    Dim uName As String
    
    uName = Application.InputBox("Enter Answer", "MOST PRODUCTIVE EMPLOYEE", Type:=2)
        
    mName = WorksheetFunction.Index(Range("A4:A9"), _
        WorksheetFunction.Match(WorksheetFunction.max(Range("D4:D9")), _
        Range("D4:D9"), 0))
            
    If uName <> mName Then
        MsgBox mName & " is the most productive employee.  Try Again!"
    Else
        MsgBox "Correct Answer - great job!"
    End If
End Sub

Open in new window


Functioning Example is attached.
MostProductive.xlsm
0
 

Author Comment

by:Frank Freese
ID: 39609201
Rgonzo1971,
Just saw your response. let me try that now.
I'm having a problem reading your VBA code. Could you post it like I would write it please?
0
 

Author Comment

by:Frank Freese
ID: 39609216
WOW! I'm getting exactly the response neede from your posts.
Great job folks looks like 50/50 and greatly appreciated
0
 

Author Closing Comment

by:Frank Freese
ID: 39609221
thanks to all!
0
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39609241
Happy to help.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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.

809 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