Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Get a total when number or rows is not know in advance

I have this code which returns a recordset from Access and pastes the results
in Excel. I need it to totall columns B and C.
The only problem is that the query will return a different number of rows
each month, so I don't know how to code the sum formula.


SQLcmd = "SELECT * FROM [S 06 Safelite Fee Summary]"

rs.Open Source:=SQLcmd, _
ActiveConnection:="Provider=Microsoft.Jet.OLEDB.4. 0; Data Source=G:\Brad and
Mary's DB.mdb" + _
"; User Id=admin; Password="


Column = 1
Row = 1

For Each fld In rs.Fields

Cells(Row, Column).Value = fld.Name
Cells(Row, Column).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid

End With
Selection.Font.Bold = True


Column = Column + 1

Next fld

Cells(2, 1).CopyFromRecordset rs

Cells.Select
Cells.EntireColumn.AutoFit

Range("A65000").End(xlUp).Offset(1, 0).Activate
ActiveCell.Value = "Fees Subtotal"



--
Billy Rogers

Dallas,TX

Currently Using SQL Server 2000, Office 2000 and Office 2003
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
I need to show the last number in a rows in the total pending row Jen S New Users to Excel 2 January 30th 09 10:30 PM
advance number by 1 when compared Edwin Armstrong Excel Discussion (Misc queries) 2 December 4th 08 05:47 PM
Get a total when number or rows is not know in advance Mike Excel Programming 0 October 2nd 07 04:13 PM
Get a total when number or rows is not know in advance Gary Keramidas Excel Programming 0 October 2nd 07 04:08 PM
Add total number of rows (text) in a column rostroncarlyle Excel Worksheet Functions 1 December 15th 05 06:25 AM


All times are GMT +1. The time now is 08:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"