View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default formatting ms access to ms excel report

you need to give us more information regarding the error message.
it is unlikely that this line of code
ws.Range("A1").CurrentRegion
will raise any errors

If you want just those two columns formatted then
ws.Range("B:C").NumberFormat = "0.00;(0.00)"

should work fine.
if cells contain TEXT, then of course, they don't get formatted, but this is
not an error.
if not, then you need to give us more details of the data or errors.




"Imran Ghani" wrote in message
...
Hi,
Thanks for your helping notes.
I have not yet been able to apply the command to the desired columns, as
there is an error message of data type mismatch. Can you please guide me
about the command which can convert data back to number from other
formats.
Regards,
Imran.

"Patrick Molloy" wrote:

change

to

ws.Range("B:C").NumberFormat = "0.00;(0.00)"

"Imran Ghani" wrote in message
...
Hi Patrick Molloy,
Thanks for your guidance. I have got my number data in column B and C.
Please guide me about how to give the above range in the following
ws.Range("A1").CurrentRegion
Regards,
Imran.


"Patrick Molloy" wrote:

when data is copied to excel from Access, they're just numbers, so
there
is
no formatting. you should open excel and use code to format the data
you can do this with Access VBA too

Sub tester()

Dim xl As Object
Dim wb As Object
Dim ws As Object

Set xl = CreateObject("Excel.Application")
''xl.Visible = True 'not required - use for testing

Set wb = xl.Workbooks.Open("C:\temp\abc.xls")
Set ws = wb.ActiveSheet

ws.Range("A1").CurrentRegion.NumberFormat = "0.00;(0.00)"

'cleanup - must have!!
Set ws = Nothing
wb.Close False
Set wb = Nothing
xl.Quit
Set xl = Nothing

End Sub


"Imran Ghani" wrote in message
...
Hi! I am exporting my report from ms access to ms excel with the
help
of
command:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"qryunionpayinv", "D:\My Reports\banking.xls", True
I am not having the exported data in the desired currency format of
"000.00", nd a small green sign is also coming with the data. Kindly
guide
me
about how to export the data with the desired format, and of course,
w/o
the
green sign, as well, I also want to have the total of the number
field
at
the
end of the records.
Kindly guide me about how to achieve my task successfully in excel.
Regards,
Imran.