PC Review


Reply
Thread Tools Rate Thread

Auto fill a list with a formula

 
 
=?Utf-8?B?S2lyayBQLg==?=
Guest
Posts: n/a
 
      6th Oct 2006
I recorded this macro, and of course it does what it's asked.

'Inserts a formula in column H to calculate Amount
Range("H2").Select
ActiveCell.FormulaR1C1 = "=RC[-3]*RC[-1]"
Selection.AutoFill Destination:=Range("H2:H65000")
Range("A2").Select

To improve this macro, I was hoping to modify it so it only copied down the
list (no matter what size the list is) - not down to row 65,000. How would I
do this?
 
Reply With Quote
 
 
 
 
Sandy
Guest
Posts: n/a
 
      6th Oct 2006
Try using this code instead

Sub test04()
Dim x, i As Integer
x = Range("G1:" & ActiveSheet.Cells(Rows.Count,
"G").End(xlUp).Address).Count
For i = 2 To x Step 1
Cells(i, 8).Formula = "=E" & i & "*G" & i
Next
End Sub

Sandy


Kirk P. wrote:
> I recorded this macro, and of course it does what it's asked.
>
> 'Inserts a formula in column H to calculate Amount
> Range("H2").Select
> ActiveCell.FormulaR1C1 = "=RC[-3]*RC[-1]"
> Selection.AutoFill Destination:=Range("H2:H65000")
> Range("A2").Select
>
> To improve this macro, I was hoping to modify it so it only copied down the
> list (no matter what size the list is) - not down to row 65,000. How would I
> do this?


 
Reply With Quote
 
Sandy
Guest
Posts: n/a
 
      6th Oct 2006
Try using this code instead

Sub test04()
Dim x, i As Integer
x = Range("G1:" & ActiveSheet.Cells(Rows.Count, "G") _
..End(xlUp).Address).Count
For i = 2 To x Step 1
Cells(i, 8).Formula = "=E" & i & "*G" & i
Next
End Sub

Sandy


Kirk P. wrote:
> I recorded this macro, and of course it does what it's asked.
>
> 'Inserts a formula in column H to calculate Amount
> Range("H2").Select
> ActiveCell.FormulaR1C1 = "=RC[-3]*RC[-1]"
> Selection.AutoFill Destination:=Range("H2:H65000")
> Range("A2").Select
>
> To improve this macro, I was hoping to modify it so it only copied down the
> list (no matter what size the list is) - not down to row 65,000. How would I
> do this?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto fill or auto search from a list or drop-down list??????? Joe H. Microsoft Excel Misc 9 29th Aug 2008 12:56 AM
Re: Auto formula fill Nick Hodge Microsoft Excel Misc 1 19th Dec 2006 06:39 PM
auto fill-in formula tony wong Microsoft Excel Programming 1 25th Oct 2006 03:47 AM
Formula auto-fill help!! daveycmc Microsoft Excel Worksheet Functions 1 11th Apr 2006 05:31 PM
auto formula fill =?Utf-8?B?Q29ubmllIE1hcnRpbg==?= Microsoft Excel Misc 1 22nd Mar 2006 06:11 PM


Features
 

Advertising
 

Newsgroups
 


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