Solved

Defining a variable correctly

Posted on 2014-03-29
4
103 Views
Last Modified: 2014-03-29
Folks,
I have a calculated value of .5226789654. However, I only need to check .5226 and my feeble attempts below are failing:

Dim Gender As Double
Gender = 0.5226
Range("E4").Select
Selection.NumberFormat = ".####"
If Range("E4").Value <> Gender Then
    MsgBox "Male % between 0-4 is wrong!", vbExclamation, "Wrong Percentage!"
    Worksheets("2DBarClustered").Range("E4").ClearContents
     Range("E4").Select
     Exit Sub
 End If

Open in new window

0
Comment
Question by:Frank Freese
  • 3
4 Comments
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
Comment Utility
Use currency data type
Dim Gender As Currency

Open in new window

0
 

Author Comment

by:Frank Freese
Comment Utility
It's not currency but a percent
0
 

Author Comment

by:Frank Freese
Comment Utility
currency seemed to work
thanks
0
 

Author Closing Comment

by:Frank Freese
Comment Utility
thank you
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
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 Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

762 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

10 Experts available now in Live!

Get 1:1 Help Now