Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Fill Down to Stop at Last Row

How can I make this to stop at the last used row? It goes to the row 65536

Sub FillDownByColumn()
Do Until y = Range("A1").CurrentRegion.Rows.Count - 1
Selection.End(xlDown).Activate
Range(Selection, Selection.End(xlDown).Offset(-1, 0)).Select
Selection.FillDown
y = Selection.Row
Loop
End Sub

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Fill Down to Stop at Last Row

Have you single-stepped through your code to watch it at work?

Range(Selection, Selection.End(xlDown).Offset(-1, 0)).Select

... selects the last cell in Column $A down to the last cell on row 655,535
on the first pass through the loop, then fills it with data.

Do Until y = Range("A1").CurrentRegion.Rows.Count - 1

....then has a CurrentRegion of the entire worksheet on the very next loop,
which becomes endless!!!
--
Regards,
Bill Renaud



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Fill Down to Stop at Last Row

Thanks Bill,

Yes I have single-stepped through the code.
I'm working with a range with several non-continuos blanks.
Whay it does is to select the cell at the top and blanks below and fill
them. Then it moves to the next cell with blanks underneath and so on. It is
identiying the last row of the range correctly, not 65536. It just doesn't
stop at it.
Do you have any other approach?
Thanks

"Bill Renaud" wrote:

Have you single-stepped through your code to watch it at work?

Range(Selection, Selection.End(xlDown).Offset(-1, 0)).Select

... selects the last cell in Column $A down to the last cell on row 655,535
on the first pass through the loop, then fills it with data.

Do Until y = Range("A1").CurrentRegion.Rows.Count - 1

....then has a CurrentRegion of the entire worksheet on the very next loop,
which becomes endless!!!
--
Regards,
Bill Renaud




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Fill Down to Stop at Last Row

OK, so if you have the following data, show us what you want to happen
(copy the table below, then fill in the blank cells):

A B C
1 123 456 789
2 234 567 897
3 234 345
4 234 545
5 234 456 456
6 123 456 789
7 234 567
8
9 234

--
Regards,
Bill Renaud



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Fill Down to Stop at Last Row

I got it figuere it out.
I wasn't referring to the variable withing the loop.

Thanks

"Bill Renaud" wrote:

OK, so if you have the following data, show us what you want to happen
(copy the table below, then fill in the blank cells):

A B C
1 123 456 789
2 234 567 897
3 234 345
4 234 545
5 234 456 456
6 123 456 789
7 234 567
8
9 234

--
Regards,
Bill Renaud






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
in Save As,how to stop auto fill in whatever the mouse hovers on? DJADe Setting up and Configuration of Excel 4 April 30th 23 03:42 AM
Stop Overwriting (Fill, Copy, etc) Data Validation Silena K-K Excel Discussion (Misc queries) 3 January 15th 08 12:05 AM
How do I stop Excel from progressing a formula in fill down or rig mbaysden Excel Worksheet Functions 2 March 15th 07 08:35 PM
stop auto fill from thinking for itself!!!!!!! 1vagrowr New Users to Excel 3 November 5th 05 03:27 PM
How do I stop other circles in other boxes to stop selecting? stauff Excel Worksheet Functions 1 October 28th 04 10:27 PM


All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"