• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

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
0
Seamus2626
Asked:
Seamus2626
  • 4
  • 2
  • 2
  • +1
1 Solution
 
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
 
IanThCommented:
can you cast it to a long
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
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
 
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
 
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.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now