[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 111
  • 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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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