How can I lock the header cell so it's not alphabetized?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a string (thanks to JW) to auto alphabetize column A in my
worksheet.... however...it's including the title cell. How can I adjust that
so it only alphabetizes from cell A2 through the rest of the worksheet.......

I SOOOOO need to take computer classes!!!!
 
This line of code will sort the entire first column while leaving the header
row as it is.

Range("a:a").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes

This command will not affect data in adjacent columns. If you wish to sort
column a with other data, you should change the Range("a:a") part to
something that matches your range (like Range("a:e") or something).

HTH,
Matthew Pfluger
 
Thanks Matthew. I also discovered there is a field in the General Tab under
Options that allows you to "ignore other applications" in specific cells.
That worked fine. Rather than mess with the string, I leave it at that.

BUT, I've copied your suggestion to keep with the original string for future
reference.
 
This option does not ignore other applications in specific cells so I don't know
how that could possibly help you.

From help...............

In Excel, click Options on the Tools menu, and then click the General tab.
Clear the Ignore other applications check box.
If this option is selected, Excel ignores requests from programs that link to
Excel data by means of DDE rather than OLE.


Gord Dibben MS Excel MVP
 
Before sorting, you must be sure that the table is properly formatted. If,
for instance, you have something like:

Some Mexican Stocks
A Date
Mark CoTicker CoName PriceHi PriceLow
1 VTO Vitro 7 5
2 GELEF Elektra 15 6
3 TMX TELMEX 10 2

All attempts to sort the data will fail, because it is not clear which cells
form the table you want to sort. Although Excel functions have error-handlers
routines that can solve the error or ambiguity, it is better to state things
clearly. In your example, the error-handler is trying to solve the error by
including the title cell.

In my example, there must be an EMPTY row between the title of the table and
the data.

Some Mexican Stocks
A Date

Mark CoTicker CoName PriceHi PriceLow
1 VTO Vitro 7 5
2 GELEF Elektra 15 6
3 TMX TELMEX 10 2

As a general comment, I think it is better to state things clearly than
state them in a confusing way (either for others or for the machine), and
then fix them with another routine. By adding an extra routine or extra code
the whole task becomes more complex.
 

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

Back
Top