Solved

Do until loop

Posted on 2012-03-16
10
267 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Suggested Solutions

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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