Article ID: 191176
Article Last Modified on 9/12/2006
A1: 1
A2: 2
A3: 3
' In this macro, cellRange is an Object variable
' and cellItem is a Variant variable.
Sub LoopTest()
Set cellRange = ActiveSheet.Range("A1:A3")
' The following concatenates an "A" to the default value of each
' cell.
For Each cellItem In cellRange
cellItem = cellItem & "A"
MsgBox cellItem
Next
' The cellRange will return the default value (not value&"A"),
' even though the loop above changed the value of the object.
For Each cellItem In cellRange
MsgBox cellItem
Next
End Sub
Dim cellItem As Object
cellItem = cellItem & "A"
to:
cellItem.Value = cellItem & "A"
176476 OFF: Office Assistant Not Answering Visual Basic Questions
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: XL98
Keywords: kbprb kbdtacode KB191176