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

1. I have a hiden worksheet that I would like to sort. So far, I am only
able to get the macro to work if I make the worksheet active in order to
sort. I need to keep the sheet hidden. Is there a way to sort a hidden
worksheet?

2. In my spreadsheet I have certain rows that are colored in background RED.
I would like to use the IF in a cell to say something like "IF A1=background
in RED, A1+2, A1*2". Is it possible?

Thanks
Kim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Sorting Macro question

Re #1, You CAN sort a worksheet that isn't active. Please post the code you
have.

Re #2, see www.cpearson.com for help with identifying background colors. BTW,
if the color is a result of conditional formatting, you can't determine what
it is by VBA code. You would have to see which of the conditional formatting
conditions is met.

On Sat, 23 Oct 2004 17:58:09 -0700, "kim" wrote:

1. I have a hiden worksheet that I would like to sort. So far, I am only
able to get the macro to work if I make the worksheet active in order to
sort. I need to keep the sheet hidden. Is there a way to sort a hidden
worksheet?

2. In my spreadsheet I have certain rows that are colored in background RED.
I would like to use the IF in a cell to say something like "IF A1=background
in RED, A1+2, A1*2". Is it possible?

Thanks
Kim


  #3   Report Post  
Posted to microsoft.public.excel.programming
kim kim is offline
external usenet poster
 
Posts: 3
Default Sorting Macro question

The code I use for sorting.
Worksheets("Sheet1").Range("A1:B7").sort Key1:=Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

It's giving me an error stating that "Sort reference is not valid."

"Myrna Larson" wrote in message
...
Re #1, You CAN sort a worksheet that isn't active. Please post the code
you
have.

Re #2, see www.cpearson.com for help with identifying background colors.
BTW,
if the color is a result of conditional formatting, you can't determine
what
it is by VBA code. You would have to see which of the conditional
formatting
conditions is met.

On Sat, 23 Oct 2004 17:58:09 -0700, "kim" wrote:

1. I have a hiden worksheet that I would like to sort. So far, I am only
able to get the macro to work if I make the worksheet active in order to
sort. I need to keep the sheet hidden. Is there a way to sort a hidden
worksheet?

2. In my spreadsheet I have certain rows that are colored in background
RED.
I would like to use the IF in a cell to say something like "IF
A1=background
in RED, A1+2, A1*2". Is it possible?

Thanks
Kim




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sorting Macro question

With Worksheets("Sheet1")
.Range("A1:B7").sort Key1:=.Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End with

the Range("B1") refers to the active sheet since it isn't qualified, so the
above qualifies it.

--
Regards,
Tom Ogilvy


"kim" wrote in message
...
The code I use for sorting.
Worksheets("Sheet1").Range("A1:B7").sort Key1:=Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

It's giving me an error stating that "Sort reference is not valid."

"Myrna Larson" wrote in message
...
Re #1, You CAN sort a worksheet that isn't active. Please post the code
you
have.

Re #2, see www.cpearson.com for help with identifying background colors.
BTW,
if the color is a result of conditional formatting, you can't determine
what
it is by VBA code. You would have to see which of the conditional
formatting
conditions is met.

On Sat, 23 Oct 2004 17:58:09 -0700, "kim" wrote:

1. I have a hiden worksheet that I would like to sort. So far, I am only
able to get the macro to work if I make the worksheet active in order to
sort. I need to keep the sheet hidden. Is there a way to sort a hidden
worksheet?

2. In my spreadsheet I have certain rows that are colored in background
RED.
I would like to use the IF in a cell to say something like "IF
A1=background
in RED, A1+2, A1*2". Is it possible?

Thanks
Kim






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Sorting Macro question

The error is because of the way you are specifying the key. You write simpley
Range("B1"). That, but definition, is a range on the active sheet. You can't
sort Sheet1 according to a column on a different sheet. You must qualify the
range, i.e.

Worksheets("Sheet1").Range("A1:B7").sort _
Key1:=Worksheet("Sheet1").Range("B1"), _

Or, to shorten the code

With Worksheets("Sheet1")
.Range("A1:B7").sort Key1:=.Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End With

Note the periods before each of the Range key words.

On Sat, 23 Oct 2004 18:46:04 -0700, "kim" wrote:

The code I use for sorting.
Worksheets("Sheet1").Range("A1:B7").sort Key1:=Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

It's giving me an error stating that "Sort reference is not valid."

"Myrna Larson" wrote in message
.. .
Re #1, You CAN sort a worksheet that isn't active. Please post the code
you
have.

Re #2, see www.cpearson.com for help with identifying background colors.
BTW,
if the color is a result of conditional formatting, you can't determine
what
it is by VBA code. You would have to see which of the conditional
formatting
conditions is met.

On Sat, 23 Oct 2004 17:58:09 -0700, "kim" wrote:

1. I have a hiden worksheet that I would like to sort. So far, I am only
able to get the macro to work if I make the worksheet active in order to
sort. I need to keep the sheet hidden. Is there a way to sort a hidden
worksheet?

2. In my spreadsheet I have certain rows that are colored in background
RED.
I would like to use the IF in a cell to say something like "IF
A1=background
in RED, A1+2, A1*2". Is it possible?

Thanks
Kim






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Sorting Macro question

Boy, I think I have a record for typos the

simpley should be simply
but should be by
Key1:= Worksheet( should be Key1:=Worksheets(

On Sat, 23 Oct 2004 21:11:42 -0500, Myrna Larson
wrote:

The error is because of the way you are specifying the key. You write simpley
Range("B1"). That, but definition, is a range on the active sheet. You can't
sort Sheet1 according to a column on a different sheet. You must qualify the
range, i.e.

Worksheets("Sheet1").Range("A1:B7").sort _
Key1:=Worksheet("Sheet1").Range("B1"), _

Or, to shorten the code

With Worksheets("Sheet1")
.Range("A1:B7").sort Key1:=.Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End With

Note the periods before each of the Range key words.

On Sat, 23 Oct 2004 18:46:04 -0700, "kim" wrote:

The code I use for sorting.
Worksheets("Sheet1").Range("A1:B7").sort Key1:=Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

It's giving me an error stating that "Sort reference is not valid."

"Myrna Larson" wrote in message
. ..
Re #1, You CAN sort a worksheet that isn't active. Please post the code
you
have.

Re #2, see www.cpearson.com for help with identifying background colors.
BTW,
if the color is a result of conditional formatting, you can't determine
what
it is by VBA code. You would have to see which of the conditional
formatting
conditions is met.

On Sat, 23 Oct 2004 17:58:09 -0700, "kim" wrote:

1. I have a hiden worksheet that I would like to sort. So far, I am only
able to get the macro to work if I make the worksheet active in order to
sort. I need to keep the sheet hidden. Is there a way to sort a hidden
worksheet?

2. In my spreadsheet I have certain rows that are colored in background
RED.
I would like to use the IF in a cell to say something like "IF
A1=background
in RED, A1+2, A1*2". Is it possible?

Thanks
Kim




  #7   Report Post  
Posted to microsoft.public.excel.programming
kim kim is offline
external usenet poster
 
Posts: 3
Default Sorting Macro question

Thanks everyone for your quick response. It's working now.

"Myrna Larson" wrote in message
...
The error is because of the way you are specifying the key. You write
simpley
Range("B1"). That, but definition, is a range on the active sheet. You
can't
sort Sheet1 according to a column on a different sheet. You must qualify
the
range, i.e.

Worksheets("Sheet1").Range("A1:B7").sort _
Key1:=Worksheet("Sheet1").Range("B1"), _

Or, to shorten the code

With Worksheets("Sheet1")
.Range("A1:B7").sort Key1:=.Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End With

Note the periods before each of the Range key words.

On Sat, 23 Oct 2004 18:46:04 -0700, "kim" wrote:

The code I use for sorting.
Worksheets("Sheet1").Range("A1:B7").sort Key1:=Range("B1"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

It's giving me an error stating that "Sort reference is not valid."

"Myrna Larson" wrote in message
. ..
Re #1, You CAN sort a worksheet that isn't active. Please post the code
you
have.

Re #2, see www.cpearson.com for help with identifying background colors.
BTW,
if the color is a result of conditional formatting, you can't determine
what
it is by VBA code. You would have to see which of the conditional
formatting
conditions is met.

On Sat, 23 Oct 2004 17:58:09 -0700, "kim" wrote:

1. I have a hiden worksheet that I would like to sort. So far, I am only
able to get the macro to work if I make the worksheet active in order to
sort. I need to keep the sheet hidden. Is there a way to sort a hidden
worksheet?

2. In my spreadsheet I have certain rows that are colored in background
RED.
I would like to use the IF in a cell to say something like "IF
A1=background
in RED, A1+2, A1*2". Is it possible?

Thanks
Kim






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
Question on sorting Michael Slater New Users to Excel 8 August 8th 07 02:56 PM
Sorting question JoAnn Paules [MVP] New Users to Excel 5 September 30th 06 04:55 PM
Row sorting question jezzica85 Excel Discussion (Misc queries) 3 May 4th 06 11:13 PM
sorting question LewR Excel Discussion (Misc queries) 4 May 3rd 06 02:10 PM
Sorting question blueglass74 Excel Discussion (Misc queries) 2 February 23rd 06 12:34 AM


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