Hello,
I am a newbie on vba. I am confused when should i use a set keyword when defining a object variable. Up to now i was in a believing that we need to use a set keyword every time we declare a object variable. In the example below we have not used a set key word after declaring the variable but the code still runs fine. I did not get it when to use a set keyword and when not too. Can anyone please clarify me the when to use a set keyword
many thanks
Sub Test_data (ByVal Myrange As Range)
Dim Cell As Range
For Each Cell In Myrange
If Cell.Column = Range("A:A").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "B").Value = Now
Else
Cells(Cell.Row, "B").Value = ""
End If
End If
Next Cell
End Sub
I am a newbie on vba. I am confused when should i use a set keyword when defining a object variable. Up to now i was in a believing that we need to use a set keyword every time we declare a object variable. In the example below we have not used a set key word after declaring the variable but the code still runs fine. I did not get it when to use a set keyword and when not too. Can anyone please clarify me the when to use a set keyword
many thanks
Sub Test_data (ByVal Myrange As Range)
Dim Cell As Range
For Each Cell In Myrange
If Cell.Column = Range("A:A").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "B").Value = Now
Else
Cells(Cell.Row, "B").Value = ""
End If
End If
Next Cell
End Sub