#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 92
Default Macro sorts

I have been having problems with macros seeming to work, then at a later
date, failing and coming up with an error.

The latest instance is where I develop the macro using the record feature. I
select a single column of a spread sheet, then sort it. When I run the
macro it errors out on the sort. If I then manually do the sort, it asks me
if I want to expand the columns. I answer NO then it proceeds as expected.
I'M guessing that this intermediate question is the problem. How do I get
around it.

I have included the code that's failing.

Columns("C:C").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Thanks for any assistance,

Craig


  #2   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Macro sorts

Which line does it fail on. I can't make it fail on my computer. (2003)

"C Brandt" wrote:

I have been having problems with macros seeming to work, then at a later
date, failing and coming up with an error.

The latest instance is where I develop the macro using the record feature. I
select a single column of a spread sheet, then sort it. When I run the
macro it errors out on the sort. If I then manually do the sort, it asks me
if I want to expand the columns. I answer NO then it proceeds as expected.
I'M guessing that this intermediate question is the problem. How do I get
around it.

I have included the code that's failing.

Columns("C:C").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Thanks for any assistance,

Craig



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 92
Default Macro sorts

I'm running Excel 2003, and it didn't fail right away for me either. I
haven't figured out the sensitivity issue yet.

When I run this manually, it asks the question, how is that resolved when
under macro control?

Craig

"bj" wrote in message
...
Which line does it fail on. I can't make it fail on my computer. (2003)

"C Brandt" wrote:

I have been having problems with macros seeming to work, then at a later
date, failing and coming up with an error.

The latest instance is where I develop the macro using the record

feature. I
select a single column of a spread sheet, then sort it. When I run the
macro it errors out on the sort. If I then manually do the sort, it asks

me
if I want to expand the columns. I answer NO then it proceeds as

expected.
I'M guessing that this intermediate question is the problem. How do I

get
around it.

I have included the code that's failing.

Columns("C:C").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending,

Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Thanks for any assistance,

Craig





  #4   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Macro sorts

That there is not a range section in the line after the selection of column
C indicates you did not expand the response when you first made the macro.

the macro would only do the selection unless the range were established

try deleting the selction line and changing the selcond line to
Range("C:C").Sort Key1:=Range("C2"), Order1:=xlAscending,
"C Brandt" wrote:

I'm running Excel 2003, and it didn't fail right away for me either. I
haven't figured out the sensitivity issue yet.

When I run this manually, it asks the question, how is that resolved when
under macro control?

Craig

"bj" wrote in message
...
Which line does it fail on. I can't make it fail on my computer. (2003)

"C Brandt" wrote:

I have been having problems with macros seeming to work, then at a later
date, failing and coming up with an error.

The latest instance is where I develop the macro using the record

feature. I
select a single column of a spread sheet, then sort it. When I run the
macro it errors out on the sort. If I then manually do the sort, it asks

me
if I want to expand the columns. I answer NO then it proceeds as

expected.
I'M guessing that this intermediate question is the problem. How do I

get
around it.

I have included the code that's failing.

Columns("C:C").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending,

Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Thanks for any assistance,

Craig






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 92
Default Macro sorts

bj

It fails on the sort. I left the column selection in there to ensure that it
was understood that the sort was on a single column.


Craig

"bj" wrote in message
...
Which line does it fail on. I can't make it fail on my computer. (2003)

"C Brandt" wrote:

I have been having problems with macros seeming to work, then at a later
date, failing and coming up with an error.

The latest instance is where I develop the macro using the record

feature. I
select a single column of a spread sheet, then sort it. When I run the
macro it errors out on the sort. If I then manually do the sort, it asks

me
if I want to expand the columns. I answer NO then it proceeds as

expected.
I'M guessing that this intermediate question is the problem. How do I

get
around it.

I have included the code that's failing.

Columns("C:C").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending,

Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Thanks for any assistance,

Craig







  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro sorts

I've never seen code pause to ask you this question. In my experience, excel
just trusts the code to know what it's doing.

But maybe this would help:

application.displayalerts = false
columns("C:C").sort key1:=....
application.displayalerts = true

(Just a guess. Your code worked fine--no prompts--for me in xl2003.)

C Brandt wrote:

I have been having problems with macros seeming to work, then at a later
date, failing and coming up with an error.

The latest instance is where I develop the macro using the record feature. I
select a single column of a spread sheet, then sort it. When I run the
macro it errors out on the sort. If I then manually do the sort, it asks me
if I want to expand the columns. I answer NO then it proceeds as expected.
I'M guessing that this intermediate question is the problem. How do I get
around it.

I have included the code that's failing.

Columns("C:C").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Thanks for any assistance,

Craig


--

Dave Peterson
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
subtotals and sorts SheriTingle Excel Discussion (Misc queries) 1 February 22nd 07 11:36 AM
Create a macro that finds values then sorts John Hughes Excel Worksheet Functions 2 August 30th 06 12:10 AM
Drop Down Box that sorts Joey041 Excel Discussion (Misc queries) 1 July 23rd 06 03:46 AM
Sorts Mona Marie Excel Worksheet Functions 3 July 21st 06 06:07 PM
Macro that sorts Hawkfan757 Excel Worksheet Functions 1 December 2nd 04 02:53 PM


All times are GMT +1. The time now is 12:55 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"