LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default autofill down until reach variable range

I need to number a form using autofill, the start cell is static but the end
cell is a variable. I have written the following code but I can't figure out
how to refer to the varable when autofilling. The code selects the entire
range but I can't figure out how to autofill from c15:LastCell. Thank you for
your help.

Sub num2()
'
' num2 Macro
' Macro recorded 10/23/2009 by tpeter
'

Dim LastCell As Range
Set LastCell = Range("C15").End(xlDown)

Range("C15").Select
ActiveCell.FormulaR1C1 = "1"
Range("C16").Select
ActiveCell.FormulaR1C1 = "2"
Range("C15:C16").Select
Selection.AutoFill Destination:=Range("C15:C30"), Type:=xlFillDefault
Range("C15:C28").Select
End Sub
 
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
Autofill with Column as a variable LuisE Excel Programming 5 August 17th 08 09:00 AM
Autofill variable range Basta1980 Excel Programming 2 March 19th 08 10:32 AM
I need to add a range of cells until I reach a cell with a zero va tower_of_love_m Excel Worksheet Functions 1 January 27th 06 09:48 AM
Variable Autofill range Kate Excel Programming 2 February 23rd 04 09:20 PM
Variable Autofill Range Kate Excel Programming 1 February 23rd 04 09:12 PM


All times are GMT +1. The time now is 03:27 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"