Sorting macro

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?
 
D

Don P

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top