Tuesday, April 9, 2019

excel - For Each cell in Range cannot bring to another Sub?

When using For Each cell in Range, I would like to use the cell.row property to refer to the row of the current cell. However if I use it in another Sub, I get the error Run-time error:'424' Object required.




Below is a simple code to illustrate what I mean. Am I doing anything wrong or is there a way to refer to the row of the current cell in another Sub? Thanks!



Sub CommandButton2_Click()

Dim rng As Range
Set rng = Range("P290:P293")

For Each cell In rng
Third
Next cell


End Sub

Sub Third()

MsgBox cell.row

End Sub

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...