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: 93
Default Copy formula to a column of cells

Cells A8 to G (whatever) are filled with an MS query, that is refreshed by
pressing a VBA button.
As well as refreshing the data the button also creates a subtotal of the
cells, breaking it by the first column (user name) and summing the last three
columns.

One thing I can't put into the spreadsheet from the query is a formula, so
this is also added in to column H when the button is pressed, as follows:-

Private Sub CommandButton1_Click()
Range("A8").select
Selection.subtotal Group:=1,
Funtion:=xlSum,TotalList:=Array(5,6,7), _

Replace:=True,PageBreaks:=False,SummaryBelowData:= True
Range("H8:H8").cells(1,1).Formula ="=IF(D="""",E8/((G8-INT(G8))*24),"""")"
Range("H8").Select
Selection.End(xlDown).Select
Selection.Autofill Destination:=Range("H8:H2000")
Range("H8LH2000").Select
Range("H8").Select
End Sub

The above code works but it fills from H8 to H2000 each time the query is
run. I want it to fill to the end of the data, if the data finishes at 200,
the it fills H8:H200, if the data finishes at G20000 then the formula is
filled H8:H20000...
Etc.
Etc.

Help please. I'm not a programmer. so all help will have to be detailed.

Thanks
Dean
 
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
copy formula down a column and have cell references change within formula brad New Users to Excel 5 May 13th 07 04:38 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
Rounding formula won't copy to other cells in column - why? LindaO Excel Discussion (Misc queries) 4 July 11th 05 10:57 PM
Copy cells to another column with VBA Joe E via OfficeKB.com Excel Discussion (Misc queries) 1 January 26th 05 04:32 PM
Copy cells when column contains data Kirk A Excel Programming 4 June 28th 04 07:50 PM


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