ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Functions and Ranges (https://www.excelbanter.com/excel-programming/284357-functions-ranges.html)

Forrest[_3_]

Functions and Ranges
 
The following code is an exerpt from an Access module that drops records into Excel. Once in Excel I want to run functions on the entire column of data like sum(c1:c52), but come up with errors. Any thoughts? Thanks in advance, Forrest

' to the Microsoft Excel spreadsheet.
Do Until Rs.EOF
For i = 0 To Rs.Fields.Count - 1
CurrentField = Rs(i)
Sheet.cells(j, i + 1).Value = CurrentField
Next i
Rs.MoveNext
j = j + 1
Loop

' Sum range of cells.
Sheet.cells(j, i).Value = Sheet.range("C50").Value + _
Sheet.range("c51").Value



patrick molloy

Functions and Ranges
 
why not just use

..Range("C2").CopyFromRecordset Rs

Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
The following code is an exerpt from an Access module

that drops records into Excel. Once in Excel I want to
run functions on the entire column of data like sum
(c1:c52), but come up with errors. Any thoughts? Thanks
in advance, Forrest

' to the Microsoft Excel spreadsheet.
Do Until Rs.EOF
For i = 0 To Rs.Fields.Count - 1
CurrentField = Rs(i)
Sheet.cells(j, i + 1).Value = CurrentField
Next i
Rs.MoveNext
j = j + 1
Loop

' Sum range of cells.
Sheet.cells(j, i).Value = Sheet.range("C50").Value + _
Sheet.range("c51").Value


.



All times are GMT +1. The time now is 04:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com