Tuesday 9 April 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...