Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to Excel With Formatting (VBA)

Status
Not open for further replies.

NMiller007

Programmer
Nov 15, 2006
65
US
I am trying to export a report (or query really) to Excel with some basic formatting. I need to change the color of one field if another field is a certain value.

If I set the field to a different color, the formatting flows over.

Because I need conditional formatting based on another field, I have used this code:
Code:
    If (Me.Changed = 1) Then
        Me.NextInsp.ForeColor = vbRed
    Else
        Me.NextInsp.ForeColor = vbBlack
    End If
When I try to export this report to Excel, all of the NextInsp fields are black.

Is there a way I can do this conditional formatting and export to Excel with the formatting in place?

Thanks!
 
I have a quick update. No conditional formatting will output to Excel. If I set a field to a different color for all instances, it will.

Help!
 



Hi,

If you perform the query FROM Excel using MS Query Data/Get External Data/New Database Query... you can query the query in Access, return the resultset, CF the resultset in Excel.

Then the NEXT time you want the data refreshed (and there are a number of automated selection you can make in Data Range Parameters) it will grab a new resultset and CF the results automatically.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top