ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cells Range Error - URGENT (https://www.excelbanter.com/excel-programming/350188-cells-range-error-urgent.html)

Digicelt

Cells Range Error - URGENT
 

HELP

Having a serious problem with CELL qualifications ...

xlExcel.Range(Cells(TrackRow, TrackCol), Cells(TrackRow, TrackCol +
SelectedCount - 1)).HorizontalAlignment = xlCenter

This line, for example, will work fine 1st time through the Access
application to generate an excel sheet, but if you try and re-run
WITHOUT shutting the app down first, gives the error "method 'CELLS' of
object _Global failed", but all other statements using xlExcel seem to
work ok.

XlExcel quits and set to nothing at end of app, so stumped. Someone
mentioned may be an error with CELLS statement. Any takers ...?

Thanks, Steve


--
Digicelt
------------------------------------------------------------------------
Digicelt's Profile: http://www.excelforum.com/member.php...o&userid=30392
View this thread: http://www.excelforum.com/showthread...hreadid=500545


Peter T

Cells Range Error - URGENT
 
Hi Steve

Cells should be qualified to the worksheet.

Dim xlWks as excel.Worksheet

' add a new sheet
Set xlWks = xlExcel.Workbooks("myBook.xls").Worksheets.Add

' or an existing sheet
'Set xlWks = xlExcel.Workbooks("myBook.xls").Worksheets.("Sheet 1")

With xlWks
..Range(.Cells(TrackRow, TrackCol), .Cells(TrackRow, TrackCol +
SelectedCount - 1)).HorizontalAlignment = xlCenter
End With

Regards,
Peter T

"Digicelt" wrote in
message ...

HELP

Having a serious problem with CELL qualifications ...

xlExcel.Range(Cells(TrackRow, TrackCol), Cells(TrackRow, TrackCol +
SelectedCount - 1)).HorizontalAlignment = xlCenter

This line, for example, will work fine 1st time through the Access
application to generate an excel sheet, but if you try and re-run
WITHOUT shutting the app down first, gives the error "method 'CELLS' of
object _Global failed", but all other statements using xlExcel seem to
work ok.

XlExcel quits and set to nothing at end of app, so stumped. Someone
mentioned may be an error with CELLS statement. Any takers ...?

Thanks, Steve


--
Digicelt
------------------------------------------------------------------------
Digicelt's Profile:

http://www.excelforum.com/member.php...o&userid=30392
View this thread: http://www.excelforum.com/showthread...hreadid=500545





All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com