Sorting in VBA

  • Thread starter Michael from Austin
  • Start date
M

Michael from Austin

I am doing serveral sorts in a macro. The code was recorded. When I run the
macro it always states that it can not determine which row in my list
contains column labels. I have to then click OK for it to assume that I want
the first row to be what it sorts by. It there a way around this?
 
A

Ajtb

Hi Michael

This is some code that I use in one of my projects, it does an alpha sort.

Shd = Sheets("Data")

Shd.Range("B5:AZ40").Sort Key1:=Shd.Range("B5"), Order1:=xlAscending

HTH
Andrew Bourke
 
M

Michael from Austin

My mistake it is not happening for the sort, it is happening when I am going
to subtotal. The message that is.....
 
T

Tushar Mehta

Dunno if this will help, but you may want to re-record the macro and
this time in the sort dialog box ensure you select the 'my data range
has header row' option.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

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