For Each Loop

ripon

Member
Joined
Mar 23, 2006
Messages
15
Programming Experience
Beginner
Hi Anyone:

Why this is wrong and what is the alternate way to do it.

xrange=CType(xlSheet.Range("A10:A15,B10:B15"), Excel.Range)

For Each c In xrange

If(c.Text ="0") Then
c.Text="-"
End If
Next

---Thanks in advance
 
Presumably you are getting some sort of error message. What does that say? That should be your first clue, and ours. You haven't declared the type of 'c'. What is it and does it have a Text property? Can an Excel.Range be enumerated in that fashion?
 
Thanks a lot. All cells in this range have numbers. But as they are in Excel, I thought I can get them as String. C is anything as we do in VBA in FOREACH loop. I dont know how can I change all the cell values in this range to a string "-" if the cell value is 0.
 
Back
Top