Clear Cells Content

G

Guest

I have this VBA code to clear cells content, but it is not clearing the
content...

Set wkSheet = Worksheets(sName)

For iCount = 53 To 92
wkSheet.Cells(nRowNumber, iCount).Clear
Next

Why?
 
D

Dave Peterson

If I wanted to clear the cell's contents, I would have used:

wksheet.cells(nrownumber, icount).clearcontents

But your code should have worked ok. Are you sure you're looking at the correct
worksheet? And the correct row?
 
J

JLatham

Pardon my confusion, but where is nRowNumber defined, and what is it's value?

As I understand the .Cells() property, it needs a (row, column) reference
and while the example formula shows a variable being used for the row
reference, I don't see where it is coming from? Could cells in wrong rows be
getting cleared?
 
Top