How come VBA if clause fails?
On Jan 17, 7:08*pm, JLGWhiz wrote:
But why didn't my
version work? Just curious
For i = 0 To maxr
* * * * If sRange.Cells(row, col).Value < "" Then
* * * * ' This if() NEVER passes - ???????????????????????
* * * * * * buffer(size) = sRange.Cells(row, col).Value
* * * * * * size = size + 1
* * * * End If
* * * * col = col + 1
* * Next i
"Zilla" wrote:
The For ... Next loop is useless because you do not use the variable i in
the intervening code to do anything. *You would need to use it like
Cells(row, i) or
Cells(i, col) depending on which way you want to move.
When you used sRange.Cells(row, col), you essentially create a circular
reference. *Cells(row, col) by definition are part of sRange. *Remember row =
sRange.Row?
You should not have used sRange as part of the cell designation but just use
the
If Cells(i, col) = *etc. * Top down Parent/Child would be
Workbook.Sheet.Range or Cell. *The cell is a range, so if you use Cells(row,
col) don't use a Range variable and vice versa.
It takes a while to pull all this stuff together, but you're getting there..
Oh, I see the coding error now in my orig code - a typical cut and
paste error! The line should be
NOT
col = col + 1
BUT THIS
col = col + i
|