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

x
?
Solved

Evaluating two cells with VBA command button

Posted on 2013-11-19
5
Medium Priority
?
279 Views
Last Modified: 2013-11-19
Folks,
Here's what I am trying to do. Users have to choose between two possible answers - Answer A or Answer B based upon the results of their formulas and interpretation of the results. Answer A and Answer B are command buttons.

I am using the command buttons to test the results of two cells B9 and D9. For example if D9 = $7,500 and B9 = $5,000 then B9 is < D9 and the user should select Answer A. I need a message box that states, "Correct because the cash outlay is $2,500 less!"
However, if that was not true and the user selected Answer A then the message box would state "Incorrect because the cash outlay is $2,500 more!"
My code below for Answer A just is not getting me there.

Private Sub cmdInvestmentA_Click()
If B9 < D9 Then
MsgBox "Correct because the total cash outlay is " & B9 - D9 & " less!"
Else
MsgBox "Incorrect because the total cash out is " & D9 - B9 & " more!"
End If
End Sub

Open in new window

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
  • 2
  • 2
5 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39660228
What are you getting?
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 39660233
Private Sub cmdInvestmentA_Click()
If Range("B9") < Range("D9") Then
MsgBox "Correct because the total cash outlay is " & Range("B9")  - Range("D9") & " less!"
Else
MsgBox "Incorrect because the total cash out is " & Range("D9") - Range("B9")  & " more!"
End If
End Sub

Open in new window

0
 

Author Comment

by:Frank Freese
ID: 39660270
Thanks - - -
0
 

Author Closing Comment

by:Frank Freese
ID: 39660271
great job!
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39660283
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

649 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