macro that uses column headings as column sort 'buttons'

  • Thread starter Thread starter Rob Benz
  • Start date Start date
R

Rob Benz

This can be done in a word table via a macro; can it be done in Excel?

Click on any column heading and entire spreadsheet is sorted on that column.
 
using this macro:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)

End Sub

i think you could do what you want. you'd have to set the target
range as the header row, & you'd have to double-click, not single-
click. but i don't have any experience with it. search the newsgroup
for "workbook_sheetbeforedoubleclick" & i'll bet you'll get some
ideas.

since this macro is a workbook macro, you have to put it in the
"ThisWorkbook" object.
hope it gets you started!
:)
susan
 
Use the BeforeDoubleClick Event on the worksheet

Within that event, use the Sort method with the "Target" variable in the
Key1 argument.

Be sure to have

Application.EnableEvents=False

At the beginning and the same line at the end, but only changed to "True".

Then all you would have to do is double click on the heading.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
 
If this is to be done for only one worksheet, you can instead of using it
within "ThisWorkbook" module, you can use it in the particular's worksheet
module, so as it doesn't have to look up the worksheet name to be sure it's
doing the sort on the proper worksheet.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
using this macro:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)

End Sub

i think you could do what you want. you'd have to set the target
range as the header row, & you'd have to double-click, not single-
click. but i don't have any experience with it. search the newsgroup
for "workbook_sheetbeforedoubleclick" & i'll bet you'll get some
ideas.

since this macro is a workbook macro, you have to put it in the
"ThisWorkbook" object.
hope it gets you started!
:)
susan
 

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