formatting in Excel using Access VBA

mudster01

Registered User.
Local time
Today, 03:34
Joined
Aug 27, 2006
Messages
10
Hi
I'm a beginner at this stuff so please be patient, have exported a table using copyfromrecordset into excel setting variables:

Dim objExcel As Excel.Application
Dim objDAORsData As DAO.Recordset
dim r as range

'when table is copied go onto do various formatting

With objExcel 'various formatting
.Columns.AutoFit 'etc

'but column 3 contains numbers which i want to format = "#,##0" while number of rows varies for each sheet & each time its exported so was trying to use.......
Set r = Range("c3")
.Range(r, r.End(xlDown)).Select
.Selection.NumberFormat = "#,##0"

...but doesn't work. I think i should be passing an address to the range object & also can i use this .range within the With objexcel.

Your help is much appreciated.

Thanks.
 
try the following:

Columns("C:C").Select
Selection.NumberFormat = "#,##0"
 
thanks......obv the best way is the simplest, but is there anything obviously wrong in the code which is not letting me do it this way....its quite useful to know as i want to add total formulas at the bottom which i guess will be found using the xldown?
 

Users who are viewing this thread

Back
Top Bottom