Solved

Defining a variable correctly

Posted on 2014-03-29
4
106 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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…
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…

856 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