+ Reply to Thread
Results 1 to 2 of 2

Cells Range Error - URGENT

  1. #1
    Registered User
    Join Date
    01-12-2006
    Posts
    1

    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

  2. #2
    Peter T
    Guest

    Re: 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.("Sheet1")

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

    Regards,
    Peter T

    "Digicelt" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1