wpanssi
10-31-2010, 12:11 PM
I am looping through some cells. I want to save the formats and values temporarily into some variable but I can't seem to do it. If I uncomment this line:
d.value = c.value
I get error: Object variable or with block variable not set.
I don't want to store the cells in excel sheet but just temporarily in my code. Can I achieve this??
Here's my code, I also attached a sample fiel with the code and some data.
Sub macro()
Dim c As Range
Set c = ActiveCell
Dim d As Range
Do While (IsEmpty(c) = False)
' Why I can't do this?
'd.Value = c.Value
MsgBox c.Value
Set c = c.Offset(0, 1)
Loop
End Sub
d.value = c.value
I get error: Object variable or with block variable not set.
I don't want to store the cells in excel sheet but just temporarily in my code. Can I achieve this??
Here's my code, I also attached a sample fiel with the code and some data.
Sub macro()
Dim c As Range
Set c = ActiveCell
Dim d As Range
Do While (IsEmpty(c) = False)
' Why I can't do this?
'd.Value = c.Value
MsgBox c.Value
Set c = c.Offset(0, 1)
Loop
End Sub