Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Auto fill a list with a formula

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Auto fill a list with a formula

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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Auto fill a list with a formula

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
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
auto fill or auto search from a list or drop-down list??????? Joe H.[_2_] Excel Discussion (Misc queries) 9 August 29th 08 12:56 AM
Auto fill/list sahbahdoo Excel Discussion (Misc queries) 1 January 31st 08 02:45 AM
Auto fill from pick list AndyB Excel Worksheet Functions 3 October 1st 07 10:54 PM
Drop Down List & Auto Fill smrsunboy New Users to Excel 2 September 3rd 07 05:56 AM
Auto-Fill in List Fields? coritsia Excel Worksheet Functions 0 December 6th 05 05:26 PM


All times are GMT +1. The time now is 12:52 PM.

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"