[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Managing a users response

Posted on 2013-10-29
8
Medium Priority
?
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 53

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
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…

656 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