?
Solved

Do until loop

Posted on 2012-03-16
10
Medium Priority
?
270 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
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!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

777 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