View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Referring to a Range Based on Selected Rows

x = selection(1).row
y = selection(selection.count).row
set rng = Range(cells(x,"B"),cells(y,"F"))


--
Regards,
Tom Ogilvy


"Sprinks" wrote in message
...
To sort a list such as the following alphanumerically, I've created
subroutines to insert a leading zero on the single-digit entries, sort,

and
then strip off the leading zero. These work fine, assuming the user has
selected the entire range to be sorted, and not just entries in this

column.

I'd like to bulletproof the macro by:
- determining the beginning and ending row of the selection (x, y)
- sorting the range Bx:Fy

Thanks for your input.

Sprinks

Pre-sort condition
--------------------
AC20
AC1
AC2
AC9
AC10

Normal Excel Sort Result
-----------------------------
AC1
AC10
AC2
AC20
AC9

Macro Sort Result
---------------------
AC1
AC2
AC9
AC10
AC20