Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Sort by Variables

OK, I'm one step further then my last question. How do I SORT using string
variables? Am I close?

dim itype1 as integer
dim itype2 as integer
dim itype3 as interger

itype1 = "Cash Equivalent"
itype2 = "Bond"
itype3 = "Common Stock"





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sort by Variables

dim itype1 as integer
dim itype2 as integer
dim itype3 as interger
Dim res1 as variant, res2 as variant, res3 as variant
Dim rng1 as Range, rng2 as Range, rng3 as Range


itype1 = "Cash Equivalent"
itype2 = "Bond"
itype3 = "Common Stock"



res1 = Application.Match(itype1,Rows(1),0)
res2 = Application.Match(itype2,Rows(1),0)
res3 = Application.Match(itype2,Rows(1),0)
if not iserror(res1) and not iserror(res2) and not iserror(res3) then
set rng1 = cells(1,res1)
set rng2 = cells(1,res2)
set rng3 = cells(1,res3)
Range("A1").currentRegion.Sort _
Key1:=rng1, order1:=xlAscending, _
Key2:=rng2, order2:=xlAscending, _
Key3:=rng3, order3:=xlAscending, _
Header:=xlYes,OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom

--
Regards,
Tom Ogilvy

"SharonInGa" wrote in message
...
OK, I'm one step further then my last question. How do I SORT using

string
variables? Am I close?

dim itype1 as integer
dim itype2 as integer
dim itype3 as interger

itype1 = "Cash Equivalent"
itype2 = "Bond"
itype3 = "Common Stock"







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
Sort by two variables at the same time MS[_3_] Excel Worksheet Functions 7 October 21st 08 03:35 AM
How do I sort variables into sets of three? mikeb Excel Discussion (Misc queries) 2 June 21st 06 12:46 AM
How do I sort a column of computed variables in EXCEL? Sylgeox Excel Worksheet Functions 2 October 3rd 05 12:07 AM
Sort with two variables Jeff New Users to Excel 2 June 30th 05 06:14 AM
sort for variables Tom Ogilvy Excel Programming 0 July 11th 03 01:18 PM


All times are GMT +1. The time now is 12:26 AM.

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"