magelan
12-10-2012, 03:23 PM
Howdy,
So in my last post I discussed finding a cell and checking it to the eventual conclusion that I would be deleting that row.
Now I have a new problem...
Post deletion, it seems as though my For-Each loop doesnt realize the index has changed, and immediately skips a bunch of cells. Here's the code.
'For k = checkRange.Rows.count To checkRange.Row Step -1
For Each cellVar In checkRange
'workingCell = cells(k,checkRange.column)
Call introCheck(cellVar, countryLocation, taxLocation, deletedRow)
If Not deletedRow Then
Call lengthCheck(cellVar)
End If
Next
As you can see, I tried making a backwards-stepping forloop instead of a forwards-running for-each loop but that broke my subroutines. i replaced cellvar with workingCell and each of the subroutines would see that as "object required" instead of the actual cell with all of its information.
Is there a fix/alternate method? Obviously the easiest way would just be to tell the For-Each loop to step backwards one step if deletedrow=true [deletedRow = true if the row was deleted during introCheck]
edit - removed irrelevant code for ease of reading
Edit2 - nevermind ---
changed one line of code to
Set workingCell = Cells(k, checkRange.Columns(1).Column) which gives the right object.
So in my last post I discussed finding a cell and checking it to the eventual conclusion that I would be deleting that row.
Now I have a new problem...
Post deletion, it seems as though my For-Each loop doesnt realize the index has changed, and immediately skips a bunch of cells. Here's the code.
'For k = checkRange.Rows.count To checkRange.Row Step -1
For Each cellVar In checkRange
'workingCell = cells(k,checkRange.column)
Call introCheck(cellVar, countryLocation, taxLocation, deletedRow)
If Not deletedRow Then
Call lengthCheck(cellVar)
End If
Next
As you can see, I tried making a backwards-stepping forloop instead of a forwards-running for-each loop but that broke my subroutines. i replaced cellvar with workingCell and each of the subroutines would see that as "object required" instead of the actual cell with all of its information.
Is there a fix/alternate method? Obviously the easiest way would just be to tell the For-Each loop to step backwards one step if deletedrow=true [deletedRow = true if the row was deleted during introCheck]
edit - removed irrelevant code for ease of reading
Edit2 - nevermind ---
changed one line of code to
Set workingCell = Cells(k, checkRange.Columns(1).Column) which gives the right object.