Essentially I have the following code I use in MS Access after Exporting an Excel. This works well for Applying the Filter Functionality and Making the Cell Values Bold, but how can I also highlight the cells of those same values?
'Specifying Tables
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Table1",".xlsx", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Table2",".xlsx", True
Call ModifyExportedExcelFileFormats(".xlsx", "Table1")
Call ModifyExportedExcelFileFormats(".xlsx", "Table2")
__
Public Sub ModifyExportedExcelFileFormats(sFile As String, sSheet As String)
Dim xlApp As Object
Dim xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
Set xlSheet = xlApp.Workbooks.Open(sFile).Sheets(1)
With xlApp
.Application.Sheets(sSheet).Select
.Application.Rows("1:1").Select
.Application.Selection.Font.Bold = True
.Application.range("A1").Select
.Application.Selection.AutoFilter
.Application.Cells.Select
.Application.Selection.Columns.AutoFit
.Application.range("A1").Select
.Application.Activeworkbook.Save
.Application.Activeworkbook.Close
.Quit
End With
End Sub
How can this properly used to only highlight the cells in the top row that have values in them?
.Application.Selection.Interior.Color = vbYellow
Range([whatever]).SpecialCells(xlCellTypeConstants).Interior.Color = vbYellow
? – BruceWayne