![]() |
Stop Loop
I have the following code.
Do Until ActiveCell.Value = "End" Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop How do I make the loop stop when the selection doesn't find any more data? At the moment it just goes to the bottom row of the workbook and fails. I've kind of guessed how to make the loop happen in the first place and I'm not that great (understatement) at VBA so help in simple terms would be appreciated! Many thanks |
Stop Loop
Sorry I should have removed the "End" piece at the start. I added that having
read another post, but then relaised that it will never find the "End" in the active cell. "pjd33" wrote: I have the following code. Do Until ActiveCell.Value = "End" Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop How do I make the loop stop when the selection doesn't find any more data? At the moment it just goes to the bottom row of the workbook and fails. I've kind of guessed how to make the loop happen in the first place and I'm not that great (understatement) at VBA so help in simple terms would be appreciated! Many thanks |
Stop Loop
Do Until ActiveCell.End(xldown).Row = rows.count
Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop -- Regards, Tom Ogilvy "pjd33" wrote: I have the following code. Do Until ActiveCell.Value = "End" Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop How do I make the loop stop when the selection doesn't find any more data? At the moment it just goes to the bottom row of the workbook and fails. I've kind of guessed how to make the loop happen in the first place and I'm not that great (understatement) at VBA so help in simple terms would be appreciated! Many thanks |
Stop Loop
That works, I'm sure it wasn't the hardest question you have ever had to
answer but I appreciated it - thanks very much for the quick response. Could you explain what the = rows.count does? "Tom Ogilvy" wrote: Do Until ActiveCell.End(xldown).Row = rows.count Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop -- Regards, Tom Ogilvy "pjd33" wrote: I have the following code. Do Until ActiveCell.Value = "End" Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop How do I make the loop stop when the selection doesn't find any more data? At the moment it just goes to the bottom row of the workbook and fails. I've kind of guessed how to make the loop happen in the first place and I'm not that great (understatement) at VBA so help in simple terms would be appreciated! Many thanks |
Stop Loop
It is an inbuilt count of the number of rows in the spreadsheet.
-- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "pjd33" wrote in message ... That works, I'm sure it wasn't the hardest question you have ever had to answer but I appreciated it - thanks very much for the quick response. Could you explain what the = rows.count does? "Tom Ogilvy" wrote: Do Until ActiveCell.End(xldown).Row = rows.count Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop -- Regards, Tom Ogilvy "pjd33" wrote: I have the following code. Do Until ActiveCell.Value = "End" Range(Selection, Selection.End(xlDown)).Select Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _ Trend:=True Selection.End(xlDown).Select Loop How do I make the loop stop when the selection doesn't find any more data? At the moment it just goes to the bottom row of the workbook and fails. I've kind of guessed how to make the loop happen in the first place and I'm not that great (understatement) at VBA so help in simple terms would be appreciated! Many thanks |
All times are GMT +1. The time now is 02:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com