Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Macro - Modular fill function

I have created a number of macros in excel. One of them uses a function that
i would like to fill down a column for as many rows as there are in the
worksheet (which will vary from time to time). I was wondering if anyone
might have a suggestion how to code this.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Macro - Modular fill function

Hi Chaz, Try this...

Sub Autofill_Range()

Dim LastRow As Long
Dim LastCol As Long
Dim rng As Range

With ActiveSheet
Set rng = .UsedRange 'try to reset lastused cell
With rng
LastRow = .Rows(.Rows.Count).Row
LastCol = .Columns(.Columns.Count).Column
End With
' Change F1 to whatever your last column is
.Range("F1").AutoFill _
Destination:=.Range("F1:F" & LastRow), Type:=xlFillDefault
' Change th above to whatever last column you have Like Y:Y
End With
'
End Sub


"Chaz" wrote:

I have created a number of macros in excel. One of them uses a function that
i would like to fill down a column for as many rows as there are in the
worksheet (which will vary from time to time). I was wondering if anyone
might have a suggestion how to code this.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Macro - Modular fill function

Im assuming you mean that the number of rows varies, as to how many rows
contain information correct? If thats true then this will work

Range("Where ever your info starts here").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Formula = "whatever you want to fill down"
Selection.FillDown

the only catch to this, is if there are blank bits of data somewhere, it
will stop at those instead.

"Chaz" wrote:

I have created a number of macros in excel. One of them uses a function that
i would like to fill down a column for as many rows as there are in the
worksheet (which will vary from time to time). I was wondering if anyone
might have a suggestion how to code this.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Macro - Modular fill function

Beyond the macro recorder (specifically, example 4)
http://www.tushar-
mehta.com/excel/vba/beyond_the_macro_recorder/index.htm

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I have created a number of macros in excel. One of them uses a function that
i would like to fill down a column for as many rows as there are in the
worksheet (which will vary from time to time). I was wondering if anyone
might have a suggestion how to code this.

Thanks

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
Fill function oic3120 New Users to Excel 0 September 21st 11 03:52 PM
Fill function Geoffric Excel Worksheet Functions 3 December 18th 07 09:51 AM
Fill Function to next Column shital shah Excel Worksheet Functions 0 August 16th 06 02:53 PM
excel modular sheets subsheets s05ullivan Excel Discussion (Misc queries) 0 November 9th 05 04:44 AM
I have a list of data, fill in the gaps. FILL function won't work Triv Excel Discussion (Misc queries) 1 September 17th 05 02:33 PM


All times are GMT +1. The time now is 03:22 AM.

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"