Help with Code

R

Ronbo

I have the following code to Id duplicates in column "I" based on user input
as to the value they are looking for, such as 125 or 125.00. This and any
whole number work fine. However, when it is not a whole number such as 9.58
conditional formatting rounds it to ten. What do I do to stop rounding and
use the actual value?


Dim nval As Long
With Worksheets("tcf")
nval = Application.InputBox("Enter Duplicate #", Type:=1)
End With

Columns("I:I").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=nval
Selection.FormatConditions(1).Interior.ColorIndex = 3

As always, your help is appreciated.

Ronbo
 
F

FSt1

hi
what is causing the rounding off is your declaration.
dim nval as long
a long is a whole number as is an integer. you need to use a declaration
that takes decimals.
dim nval as single (or double)

in vb help look up data types.

regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top