Solved

Do until loop

Posted on 2012-03-16
10
269 Views
Last Modified: 2012-03-20
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
Comment
Question by:Seamus2626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 18

Expert Comment

by:Cluskitt
ID: 37728839
Do Until ActiveCell.Row = EndOfRows

You can't compare a type Row with a type Long.
0
 

Author Comment

by:Seamus2626
ID: 37728841
Whats the solution? I want to declare the last row and loop until that condition is met

Thanks
Seamus
0
 
LVL 30

Expert Comment

by:IanTh
ID: 37728881
can you cast it to a long
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:Seamus2626
ID: 37728886
"can you cast it to a long"


Im not sure what that means Ian?

Thanks
Seamus
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 37728895
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
 

Author Comment

by:Seamus2626
ID: 37728908
perfect!

thanks
Seamus
0
 
LVL 18

Accepted Solution

by:
Cluskitt earned 500 total points
ID: 37728947
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
 
LVL 24

Expert Comment

by:StephenJR
ID: 37728979
Fair point, I had missed that.
0
 

Author Closing Comment

by:Seamus2626
ID: 37741419
Thanks and Apologies Cluskitt, i should have seen that.

Thanks too Stephen for your comment

Seamus
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question