Delete negative number with decimal

somenoob

Board Regular
Joined
Sep 19, 2011
Messages
100
Hi. I am having a problem. I have this codes

Dim threshold As Long
threshold = 0.5
Dim negativeThreshold As Long
negativeThreshold = 0
Dim logic As String
logic = (ws.Range("C" & x) = "check") And Val(ws.Range("D" & x))

If logic > threshold Or logic < negativeThreshold Then
ws.Range("E" & x).Value = "->Chk_" & counter
counter = counter + 1
Else
ws.Range("E" & x).Value = ""
End If

Next x

i want to check for values lesser than 0. As in negative values. But it can get -1. but not -0.1

please help
<!-- / message -->
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
logic (dimensioned as a string, although I'm not sure why) is only going to hold a 1 or a 0 due to the logic statement assigning it a value. What are you hoping to achieve here?
 
Upvote 0
i see. i have change it. Thanks

I have a question to ask.

<TABLE style="WIDTH: 87pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=116 x:str><COLGROUP><COL style="WIDTH: 87pt; mso-width-source: userset; mso-width-alt: 3299" width=116><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #ccffff; WIDTH: 87pt; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl68 height=20 width=116 align=right x:num="94610.15">94,610.15 </TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #ccffff; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl68 height=20 align=right x:num="94610.15">94,610.15 </TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #ccffff; HEIGHT: 15.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl67 height=21 x:num="-1.4551915228366852E-11"> (0.00)</TD></TR></TBODY></TABLE>

i have one part in my excel that display the above. it means that 94,610.15 - 94,610.15 will give me 0. but why is it that the 0 is displayed as (0.00)? when i click on the cell, it shows
-1.45519152283669E-11
it should be 0.
 
Upvote 0
Yes, you can use the Round() function:

Code:
 dblResult = Round(dblVal1 - dblVal2,2)

where dblResult, dblVal1 and dblVal2 are decimal (Double) variables and the 2 on the end is the number of decimal places you want to round to (adjust as required).
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,308
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top