Solved

Do until loop

Posted on 2012-03-16
10
264 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
  • 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
 

Author Comment

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


Im not sure what that means Ian?

Thanks
Seamus
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now