Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default error question

I'm running an Excel macro from an Outlook module. I can automate this
process when a reminder kicks off. The macro has been working until this
week.

This is my variable: Public xlApp As Excel.Application

I create a new Excel application at the beginning of the macro:

Set xlApp = New Excel.Application
xlApp.Visible = True
xlApp.Workbooks.Add

I then do some stuff and I now want to select the data and sort it

The next line works and the appropriate data is selected

xlApp.Range("A2:Y2").Select

However, when the next line is run, it kicks me out of the Outlook module

xlApp.Range(Selection, Selection.End(xlDown)).Select

Any ideas why this is happening? It had been working fine for several weeks
but now it won't finish. Any suggestions would be appreciated. Thanks for
the help...

--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default error question

I suspect the active worksheet has changed. In the following line you are
referencing a workbook and a range without the sheet.

from
xlApp.Range("A2:Y2").Select
to
xlApp.sheets("Sheet1").Range("A2:Y2").Select

---------------------------------------------

I don't like the select method you are using. You don't have to select.

from
xlApp.Range(Selection, Selection.End(xlDown)).Select
to
with xlApp.Sheets("Sheet1")
set FirstCell = .Range("A2")
LastRow = FirstCell.end(xldown).Row
Set LastCell = .Range("Y" & LastRow)
Set DataRange = .Range(Firstcell,LastCell)
end with



"JT" wrote:

I'm running an Excel macro from an Outlook module. I can automate this
process when a reminder kicks off. The macro has been working until this
week.

This is my variable: Public xlApp As Excel.Application

I create a new Excel application at the beginning of the macro:

Set xlApp = New Excel.Application
xlApp.Visible = True
xlApp.Workbooks.Add

I then do some stuff and I now want to select the data and sort it

The next line works and the appropriate data is selected

xlApp.Range("A2:Y2").Select

However, when the next line is run, it kicks me out of the Outlook module

xlApp.Range(Selection, Selection.End(xlDown)).Select

Any ideas why this is happening? It had been working fine for several weeks
but now it won't finish. Any suggestions would be appreciated. Thanks for
the help...

--
JT

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
#VALUE ERROR Question Brent Excel Discussion (Misc queries) 1 May 13th 10 12:32 AM
Error msg question April Excel Discussion (Misc queries) 4 October 14th 06 08:37 PM
Another Error 91 question!? escudolm Excel Programming 3 December 12th 05 10:33 PM
'On Error' question GEB Excel Programming 1 June 29th 05 08:49 PM
Drillthrough MDX ERROR(Error.Number:-21467259) ?(urgent question) Microlong Excel Programming 2 March 4th 05 01:55 AM


All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"