?
Solved

Defining a variable correctly

Posted on 2014-03-29
4
Medium Priority
?
109 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
[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
  • 3
4 Comments
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 39964167
Use currency data type
Dim Gender As Currency

Open in new window

0
 

Author Comment

by:Frank Freese
ID: 39964179
It's not currency but a percent
0
 

Author Comment

by:Frank Freese
ID: 39964262
currency seemed to work
thanks
0
 

Author Closing Comment

by:Frank Freese
ID: 39964263
thank you
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
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 on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

801 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