Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Do until loop

Posted on 2012-03-16
10
Medium Priority
?
271 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

604 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