Andyatwork
Board Regular
- Joined
- Mar 29, 2010
- Messages
- 94
Hey all,
I am trying to use Find to scan a column of (thousands of) values and when it finds a value = 0 to cut the entire row and boot it to a dump tab.
It works, but it is also selecting values up to 0.4999 and I want those to be left where they are.
My code;
I thought about making the search term a variable and defining it as NOT <> 0 but realised that was a super backwards way fo saying =0, but I want zero to be zero, not anything up to nearly 0.5.
I considered doing some data faffing;
sort of thing, but this .find is being run on potentially tens of thousands of rows of data and the whole project is slow enough already so I don't want to add another calculation.
Any tips on getting .Find to recognise 0 and only 0?
Many thanks,
Andy
I am trying to use Find to scan a column of (thousands of) values and when it finds a value = 0 to cut the entire row and boot it to a dump tab.
It works, but it is also selecting values up to 0.4999 and I want those to be left where they are.
My code;
Code:
Sub zeroShares()
' Searches Share Balance column of Merged Leavers data set for value 0
' and purges them to the Zero Shares tab
Dim i As Long 'counter
Dim fndRng As Range 'found cell containing search term
Dim lrow As Long, lcol As Long
Dim zCount As Long
zCount = 1
' Check share balance column on data tab for any records showing zero shares
With shData.Range("I:I")
Application.StatusBar = "Removing holders with zero shares..."
Set fndRng = .Find(what:="0", After:=.Cells(.Cells.Count), _
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, searchdirection:=xlNext, _
MatchCase:=False)
If Not fndRng Is Nothing Then
Do
zCount = zCount + 1
fndRng.EntireRow.Cut ShZero.Range("A" & zCount)
Set fndRng = .FindNext(fndRng)
Loop While Not fndRng Is Nothing
End If
End With
End Sub
I thought about making the search term a variable and defining it as NOT <> 0 but realised that was a super backwards way fo saying =0, but I want zero to be zero, not anything up to nearly 0.5.
I considered doing some data faffing;
Code:
If value < 0.5 AND > 0 then value = 0
Any tips on getting .Find to recognise 0 and only 0?
Many thanks,
Andy