?
Solved

Managing a users response

Posted on 2013-10-29
8
Medium Priority
?
182 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 54

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 1000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 18

Accepted Solution

by:
Steven Harris earned 1000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

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