Do until loop

Hi,

I have a loop

Do Until Rows(ActiveCell.Row) = EndOfRows

At the beginning of the sub i declared

Dim EndOfRows As Long

EndOfRows = Range("C" & Rows.Count).End(xlUp).Row


I get a type mismatch error

Why is this?

Thanks
Seamus
Seamus2626Asked:
Who is Participating?
 
CluskittCommented:
That is exactly what I said in my post. I presented the necessary change for it to work and then explained why it wasn't workin before.
0
 
CluskittCommented:
Do Until ActiveCell.Row = EndOfRows

You can't compare a type Row with a type Long.
0
 
Seamus2626Author Commented:
Whats the solution? I want to declare the last row and loop until that condition is met

Thanks
Seamus
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
IanThCommented:
can you cast it to a long
0
 
Seamus2626Author Commented:
"can you cast it to a long"


Im not sure what that means Ian?

Thanks
Seamus
0
 
StephenJRCommented:
This maybe?
Dim EndOfRows As Long

EndOfRows = Range("C" & Rows.Count).End(xlUp).Row

Do Until ActiveCell.Row = EndOfRows
'
Loop

Open in new window

0
 
Seamus2626Author Commented:
perfect!

thanks
Seamus
0
 
StephenJRCommented:
Fair point, I had missed that.
0
 
Seamus2626Author Commented:
Thanks and Apologies Cluskitt, i should have seen that.

Thanks too Stephen for your comment

Seamus
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.