View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Duncan_J Duncan_J is offline
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