No it didnt work either....
Here is my code.. I am creating an excel file from access queries(for tabs in it)....Need sum of column J....
Here is my all code..
Dim fName As String
Dim dtToday As Date
Dim striType As String
dtToday = Now()
strDt = "_" & DatePart("m", dtToday) & "-" & DatePart("d", dtToday) & "-" & DatePart("yyyy", dtToday)
fName = "C:\UBICUpgradeStatusExport" & strDt & ".xls"
'& Now() & ".xls"
Dim myXL As Excel.Application
Dim myWorkbook As Excel.Workbook
Dim myWorksheet As Worksheet
Dim myRange, myRange2, myrange3, bottomcell, currentcell As Range
Dim c As Worksheet
Dim i, count, j, result, temp As Integer
Set myXL = New Excel.Application
'Open your workbook:
Dim objExcel As Object
'myXL.Visible = True
If Dir(fName) <> "" Then
Set myWorkbook = myXL.Workbooks.Open(fName)
'For Each c In myWorkbook.Worksheets
myWorkbook.Close
Set myWorkbook = Nothing
'Next
myXL.UserControl = False
Set myXL = Nothing
'FileCopy fName, fName
Kill fName
End If
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query1", fName, True, "CST"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query2", fName, True, "IC-EXTERNAL"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query3", fName, True, "IC-INTERNAL"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query4", fName, True, "UBI"
'Start Excel
i = 1
Set myXL = New Excel.Application
Set myWorkbook = myXL.Workbooks.Open(fName)
For Each c In myWorkbook.Sheets
j = 1
result = 0
'(watch out for the line break above... that should all be on one line...)
Set myWorksheet = myWorkbook.Sheets.Item(i) 'Use the name of the sheet
myWorksheet.Activate
Set myRange = myWorksheet.Range("A1:Q1")
Set myRange2 = myWorksheet.Range("A:Q")
Set myrange3 = myWorksheet.Range("J:J")
myRange.Font.Bold = True
myRange.Interior.ColorIndex = 15
myRange.EntireColumn.Columns.AutoFit
myRange2.Rows.AutoFit
Set bottomcell = myWorksheet.Cells(65536, 10).End(xlUp)
Set currentcell = myWorksheet.Range(Cells(2, 10), bottomcell)
bottomcell.Offset(1, 0).Value = WorksheetFunction.Sum(currentcell)
i = i + 1
Next
myXL.Workbooks.Close
ActiveWindow.Close
myXL.Quit
Set myXL = Nothing