PDA

View Full Version : Region



zirus
11-14-2006, 04:18 AM
hi

on my sheet i have a range ("myRange") which is the entire sheet.
on a userform i have a combobox populated off this sheet using myRange.
myRange is then sorted alphabetically using column A
the end result in the combobox is as i need it, but the problem is i get all the empty cells inserted into my combobox.

if i select and sort current region will this help, and how do select current region?

regards
:banghead:

Bob Phillips
11-14-2006, 04:29 AM
Use a dynamic range

=OFFSET($A$1,,,COUNTA($A:$A),COUNTA($1:$1))

johnske
11-14-2006, 04:33 AM
hi

on my sheet i have a range ("myRange") which is the entire sheet.
on a userform i have a combobox populated off this sheet using myRange.
myRange is then sorted alphabetically using column A
the end result in the combobox is as i need it, but the problem is i get all the empty cells inserted into my combobox.

if i select and sort current region will this help, and how do select current region?

regards
:banghead:If you want a macro to do this you're probably better off using the used range e.g.
Option Explicit

Sub TryThis()
Sheet1.UsedRange.Sort Key1:=Range("A1"), _
Order1:=xlAscending, _
Header:=xlGuess, _
Orientation:=xlTopToBottom
End Sub