Highlighting Rows in Excel from Access VBA

CPGDeveloper

Board Regular
Joined
Oct 8, 2008
Messages
174
I'm exporting a query to an excel spreadsheet. Through Access VBA, I would like to be able to highlight certain rows in the excel output -- specifically rows where a particular column equals a particular value (e.g. Where 'Date' = 3/5 etc). I would also like to be able to do some formatting, change some fonts, etc.

Any help in getting me starting would be much appreciated.

Thank You!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
What do you need help with exactly? I'm assuming you have VBA experience in working with Access and Excel. If you're just having trouble automating Excel from Access, then does this help?
Code:
Sub AutomateExcelFromAccess()
    'Early Binding (Set a reference to the Excel Object Model)
    Dim EarlyBoundXl As Excel.Application
    Set EarlyBoundXl = New Excel.Application
    
    EarlyBoundXl.Workbooks.Add
    
    While EarlyBoundXl.Workbooks.Count
        EarlyBoundXl.Workbooks(1).Close False
    Wend
    EarlyBoundXl.Quit
    
    'Late Binding
    Dim LateBoundXl As Object
    Set LateBoundXl = CreateObject("Excel.Application")
    
    LateBoundXl.Quit
End Sub
Microsoft recommends Early Binding in most situations, but here is an article if you'd like to decide for yourself: Using early binding and late binding in Automation
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,981
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top