AThom10731
IS-IT--Management
I have a MS access database and am able to export the data to a single excel file with multiple worksheets. Each worksheet is labeled with a site name. When I export the data, I would like to be able to format the data in VBA code or export to a template.
I run the code from a command button that runs the query and uses TransferSpreadsheet. Based on the values of data, I would like to fill a cell with green or red, or yellow, make the column headers bold and centered, wrap text in large columns, center a few of the columns, etc. I am not an excel expert. Please help.
Private Sub Command1_Click()
'Created a new Form called frm_CAPSummaryForm1
'and set it's RecoredSource to:
'SELECT [F_Site] FROM SEC_FindingRecords GROUP BY [F_Site];
'Added the field [F_Site] to the Detail section of the form.
'Added a Command Button (Command1) to the form with the following code:
Me.Recordset.MoveFirst
Do
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "CAP_Summary_Qry", "C:\CAPSpreadsheet.xls", True, Me.F_Site
Me.Recordset.MoveNext
Loop Until Me.Recordset.EOF
End Sub
‘My query: (CAP_Summary_Qry):
'SELECT *
'FROM SEC_FindingRecords
'WHERE ((([SEC_FindingRecords].F_Site])=[Forms]![frm_CAPSummaryForm1]![F_Site]));
I run the code from a command button that runs the query and uses TransferSpreadsheet. Based on the values of data, I would like to fill a cell with green or red, or yellow, make the column headers bold and centered, wrap text in large columns, center a few of the columns, etc. I am not an excel expert. Please help.
Private Sub Command1_Click()
'Created a new Form called frm_CAPSummaryForm1
'and set it's RecoredSource to:
'SELECT [F_Site] FROM SEC_FindingRecords GROUP BY [F_Site];
'Added the field [F_Site] to the Detail section of the form.
'Added a Command Button (Command1) to the form with the following code:
Me.Recordset.MoveFirst
Do
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "CAP_Summary_Qry", "C:\CAPSpreadsheet.xls", True, Me.F_Site
Me.Recordset.MoveNext
Loop Until Me.Recordset.EOF
End Sub
‘My query: (CAP_Summary_Qry):
'SELECT *
'FROM SEC_FindingRecords
'WHERE ((([SEC_FindingRecords].F_Site])=[Forms]![frm_CAPSummaryForm1]![F_Site]));