Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 113
  • Last Modified:

Defining a variable correctly

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
Frank Freese
Asked:
Frank Freese
  • 3
1 Solution
 
aikimarkCommented:
Use currency data type
Dim Gender As Currency

Open in new window

0
 
Frank FreeseAuthor Commented:
It's not currency but a percent
0
 
Frank FreeseAuthor Commented:
currency seemed to work
thanks
0
 
Frank FreeseAuthor Commented:
thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now