Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AutoFilling To A Variable Number Of Rows


I'm new to programming in VBA so please have some patience with m
ignorance.

I am trying write some VBA code to AutoFill a column with a formula
Normally, I can just use:

Range("C1").Select
ActiveCell.FormulaR1C1 = "=RC[-2]/RC[-1]"
Range("C1").Select
Selection.AutoFill Destination:=Range("C1:C10"), Type:=xlFillDefault
Range("C1:C10").Select

The problem is, the number of rows is variable so I don't want to se
the number of rows finitely to 10.

How can I AutoFill the column to the number of rows that matches th
number of rows of data? I know there is an END property that exists
Can I use that?

Any help is greatly appreciated. Thanks in advance.

Regards,
Wai Shin

--
Shin
-----------------------------------------------------------------------
Shing's Profile: http://www.excelforum.com/member.php...fo&userid=3603
View this thread: http://www.excelforum.com/showthread.php?threadid=55822

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default AutoFilling To A Variable Number Of Rows

Sub tst()
' find first non emty cells in column A from bottom up (r)
r = Cells(65500, 1).End(xlUp).Row

Range("C1").Select
ActiveCell.FormulaR1C1 = "=RC[-2]/RC[-1]"
Range("C1").Select
Selection.AutoFill Destination:=Range("C1:C" & r), Type:=xlFillDefault

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AutoFilling To A Variable Number Of Rows


Thanks very much. That worked a treat.

Regards,
Wai Shing


--
Shing
------------------------------------------------------------------------
Shing's Profile: http://www.excelforum.com/member.php...o&userid=36031
View this thread: http://www.excelforum.com/showthread...hreadid=558222

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
Inserting Variable Number of Rows bundyloco[_7_] Excel Programming 2 August 29th 05 11:25 AM
change the number of rows to a variable minrufeng[_6_] Excel Programming 2 August 15th 05 10:03 PM
change the number of rows to a variable theguz[_4_] Excel Programming 0 August 15th 05 09:55 PM
Autofilling a formula to a variable last cell Brian Murphy[_3_] Excel Programming 5 December 5th 03 02:21 AM
deleting variable number of rows Nick Excel Programming 1 October 29th 03 04:31 PM


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