After poking around at bit, I came up with these formatting
code examples:
' Point to a range:
Set objRNG1 = objWS.Range("A1", "Z1")
' Put borders around each cell:
For Each objRNG2 In objRNG1.Cells
objRNG2.BorderAround xlContinuous, _
xlMedium, xlColorIndexAutomatic, _
RGB(255, 255, 255)
Next
' Format the whole range:
With objRNG1
' Shade each cell:
With .Interior
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
With .Font
.Size = 12
.Bold = True
.FontStyle = "Arial"
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
' Format various columns in different
' number formats:
' General number format:
Set objRNG1 = objWS.Columns(2)
objRNG1.NumberFormat = "General"
' Currency format
' (positive in black, negative in red)
Set objRNG1 = objWS.Columns(3)
objRNG1.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
' Time format:
Set objRNG1 = objWS.Columns(4)
objRNG1.NumberFormat = "hh:mm:ss"
' Point to top left corner:
Set objRNG1 = objWS.Range("A1")
' Expand range to embrace all contiguous data:
Set objRNG1 = objRNG1.CurrentRegion
' Sort data:
' Put cursor on the words "Sort" and
' "SortSpecial", press F1, and read help
' topics to determine which parameters to
' use after the words Sort and SortSpecial.
objRNG1.Sort
' or:
objRNG1.SortSpecial
Sorting in Excel looks complicated.
I would sort the recordset before copying it to Excel.
Geoff
I have one more question. How can I format my range to
center alignment? Also
[quoted text clipped - 10 lines]
this because the
columns are not even size.