Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Fill emply column with formula

I have entered a formula into M2. Now I want to fill it to the last column
which has data in it. When I double-click on the fill handle, I get what I
want.

However, when I record the action as a macro, I get:

Selection.AutoFill Destination:=Range("M2:M3085")

I don't want the range hard-coded, because the next time I use the macro the
number of rows will be different. When I change the range to
M2...end(xldown), I get M2:M65536.

How do I specify a range which has the same effect as double-clicking on the
fill handle?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Fill emply column with formula

Selection.AutoFill Destination:=Range("M2", _
Cells(rows.count,"L").End(xlup).Offset(0,1))

--
Regards,
Tom Ogilvy

Fred Smith wrote in message
...
I have entered a formula into M2. Now I want to fill it to the last column
which has data in it. When I double-click on the fill handle, I get what I
want.

However, when I record the action as a macro, I get:

Selection.AutoFill Destination:=Range("M2:M3085")

I don't want the range hard-coded, because the next time I use the macro

the
number of rows will be different. When I change the range to
M2...end(xldown), I get M2:M65536.

How do I specify a range which has the same effect as double-clicking on

the
fill handle?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Fill emply column with formula

Fred

Assuming Column L is the adjacent column with data.

Sub Auto_Fill()
Dim Lrow As Long
With ActiveSheet
Lrow = Range("L" & Rows.Count).End(xlUp).Row
Range("M2:M" & Lrow).FillDown
End With
End Sub

Gord Dibben Excel MVP

On Wed, 4 Feb 2004 21:32:34 -0600, "Fred Smith" wrote:

I have entered a formula into M2. Now I want to fill it to the last column
which has data in it. When I double-click on the fill handle, I get what I
want.

However, when I record the action as a macro, I get:

Selection.AutoFill Destination:=Range("M2:M3085")

I don't want the range hard-coded, because the next time I use the macro the
number of rows will be different. When I change the range to
M2...end(xldown), I get M2:M65536.

How do I specify a range which has the same effect as double-clicking on the
fill handle?


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
Auto Fill formula from a column to row Margy Excel Discussion (Misc queries) 1 October 20th 08 05:15 PM
fill column with formula Margo Excel Worksheet Functions 3 October 31st 07 03:28 PM
Fill Formula Not Adjusting Down the Column lost in excel Excel Discussion (Misc queries) 2 July 5th 07 08:05 PM
Fill a column with a formula kevcar40 Excel Discussion (Misc queries) 1 March 14th 07 12:55 PM
I want Excel to regard emply cells as zero and display it gencerm Excel Discussion (Misc queries) 2 December 25th 06 08:17 PM


All times are GMT +1. The time now is 06:25 PM.

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

About Us

"It's about Microsoft Excel"