View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default Sorting a Range using VBA


The following is literally what you asked .....

Range(Cells(1, "B"), Cells(2, NumCount)).Sort Key1:=Cells(1, NumCount)

but be careful in specifying the range sort keys. You can also use the
number of the column eg 2 not "B" as you asked.
also note that when defining a range using Cells the first value is the row
number, the second the column.
--
Cheers
Nigel



"SystemHack" wrote
in message ...

Assume that I have a variable "NumCount" and I want to sort the range of
cells from (1,B) to (2,NumCount), sort by the first column accending
order. What kind of code could I use ?


--
SystemHack
------------------------------------------------------------------------
SystemHack's Profile:

http://www.excelforum.com/member.php...o&userid=26614
View this thread: http://www.excelforum.com/showthread...hreadid=399388