ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA's Q? Printing None-Zero Valye ONLY (https://www.excelbanter.com/excel-programming/445061-vbas-q-printing-none-zero-valye-only.html)

Mike

VBA's Q? Printing None-Zero Valye ONLY
 
Hi everyone,

I have this VBA piece of code and want Activity value to be written
only if it is none-zero:

Do While varVect.PosValid
If varVect.Variable 0 Then
line = line + 1
CRngSolution(line, 1).Value = subMr.Value
CRngSolution(line, 2).Value = subAcf.Value
CRngSolution(line, 3).Value = subLo.Value
CRngSolution(line, 4).Value = varVect.Variable.Activity
End If
varVect.MoveNextPos
Loop

But it is still writing zeros and non-zeros! Anything wrong?

Thanks,
Mike

Adrian C[_2_]

VBA's Q? Printing None-Zero Valye ONLY
 
On 17/10/2011 20:31, Mike wrote:
Hi everyone,

I have this VBA piece of code and want Activity value to be written
only if it is none-zero:

Do While varVect.PosValid
If varVect.Variable 0 Then
line = line + 1
CRngSolution(line, 1).Value = subMr.Value
CRngSolution(line, 2).Value = subAcf.Value
CRngSolution(line, 3).Value = subLo.Value
CRngSolution(line, 4).Value = varVect.Variable.Activity
End If
varVect.MoveNextPos
Loop

But it is still writing zeros and non-zeros! Anything wrong?

Thanks,
Mike


Try

If varVect.Variable.Activity 0 Then

or look at what variable type varVect.Variable.Activity actually returns
for the above comparision. Maybe it's never exactly 0.

--
Adrian C



All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com