Sorting macro

  • Thread starter Thread starter Butch Cassidy
  • Start date Start date
B

Butch Cassidy

I have a database with 4 columns and 900-2000 rows depending on the number
of items that we have. The first column is for the name of the product
while columns B, C and D are derived from column A via formulas. I have
created a button that will sort the rows. However, I still have to manually
designate the number of rows to sort because the number of rows changes. If
I sort ascending then any rows that are blank come out at the top. I would
like to only sort those rows that are not blank. Any help?
 
Try something like this:

Sub test()
Range("a1").CurrentRegion.Sort Key1:=Cells(1, 1), Order1:=xlAscending,
Orientation:=xlTopToBottom, Header:=True
End Sub

Assumes there is a header row and that the database starts in column A


Don Pistulka
 
Back
Top