Dear all
I want some code that exits a Do...loop when there is no more data below the activecell in column A? That is no data at all anywhere below the activecell in column A.
Is this possible?
Thanks
JAmes
Dear all
I want some code that exits a Do...loop when there is no more data below the activecell in column A? That is no data at all anywhere below the activecell in column A.
Is this possible?
Thanks
JAmes
Last edited by Jim28; 12-02-2010 at 04:54 PM.
Hi Jim28
Like this?The code finds the last row used in column A and performs the loop until it finds it.![]()
Option Explicit Public Sub test() Dim LR As Long Dim i As Long LR = Range("A" & Rows.Count).End(xlUp).Row i = 1 Do Cells(i, 1) = i i = i + 1 Loop Until i = LR + 1 End Sub
John
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please mark your Thread as SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Hi
This assumes your code moves the active cell on each iteration of the loop
HTH![]()
Sub ExitWhenNoMoreData() Dim lCount As Long lCount = 1 Do Until lCount = 0 lCount = Application.WorksheetFunction.CountA(Range(ActiveCell, Range("A" & Rows.Count))) 'your code' Loop End Sub
Richard Buttrey
RIP - d. 06/10/2022
If any of the responses have helped then please consider rating them by clicking the small star iconbelow the post.
![]()
Sub Macro1() Dim lcount As Long Range("A1").Select Do If ActiveCell <> 1 Then ActiveCell.Rows("1:1").EntireRow.Select Selection.Delete Shift:=xlUp ActiveCell.Select Else ActiveCell.Offset(1, 0).Select End If lcount = Application.WorksheetFunction.CountA(Range(ActiveCell, Range("A" & Rows.Count))) Loop Until lcount = 0 End Sub
Perfect! Thanks :_
What is your code supposed to do?
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks