Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Menubar to Sort

I want to create a menubar item to sort by specific columns only certain
rows of information. I need it to have a drop-down section outlining the
information to be sorted.
ex.
Menubar........................................Sor t
.................................................. ..........by region
.................................................. ..........by district
.................................................. ..........by volume


I need each sorted by volume inside of the sort chosen. And a Separate
sort by volume only. Volume is in column BK
The rows I need to sort are rows 55 through 250.

I have created columns A -F
and listed my data to fit into categories in these columns
Region|District|Ad|BRAC|Proj|Closed
0|3|X|0|0|0
0|2|X|0|0|0

Can someone help me in creating a menubar item that will provide me a
dropdown for the above mentioned sorts?

Matt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Menubar to Sort


Hello Matt,

These macros will add a ComboBox control to the Cell Context Menu
(right-click) with the three choices you described. I left the code for
the sorting routines blank because I wasn't clear on how the data was to
be sorted and whether you are useing named ranges on the worksheet.

Installing the Macros:
1) Copy all the macro code here using CTRL+C
2) Open the Workbook you want to the macros in.
3) Press ALT+F11 to launch the VBA Editor.
4) Press ALT + I to display the Insert menu.
5) Press M to insert a Module into your Workbook.
6) Press CTRL+V to paste the macros into the module.
7) Press CTRL+S to Savve the macros.

Adding/Removing the Sort ComboBox:
The ComboBox can be Added or Removed manually at anytime by running the
desired macro form the Macro List. To see the list of available macros,
press ALT+F8. Select either AddMenuComboBox or RemoveMenuComboBox.

The ComboBox can be added to the menu automatically by adding the
following code to your Workbooks Open event procedure.
1) Copy the Event Code using CTRL+C
2) Press CTRL+R to move the cursor back to the Project Viewer.
3) Use the Up or Down Arrow keys to select ThisWorkbook.
4) Press the Enter key.
5) Press Ctrl+V to Paste the event code.
6) Press Ctrl+S to Save the code.

'Event Code
Private Sub Workbook_Open()
Call AddMenuComboBox
End Sub


'Menu Macros...
Sub AddMenuComboBox()

Dim CmdBar As CommandBar
Dim CmdBarCombo As CommandBarComboBox

Set CmdBar = Excel.CommandBars("cell")
With CmdBar.Controls
Add Type:=msoControlComboBox, Temporary:=True
End With

Set CmdBarCombo = CmdBar.Controls(CmdBar.Controls.Count)
With CmdBarCombo
Caption = "Sort by"
BeginGroup = True
AddItem "Region"
AddItem "District"
AddItem "Volume"
OnAction = "MySortMacro"
End With

End Sub

Sub RemoveMenuComboBox()

Dim CmdBar As CommandBar
Dim CmdBarCtrl As CommandBarControl

Set CmdBar = Excel.CommandBars("Cell")

On Error Resume Next
CmdBar.Controls("Sort by").Delete

End Sub

Sub MySortMacro()

Dim Choice As String

With Excel.CommandBars("Cell").Controls("Sort by")
Choice = .Text
Text = ""
End With

Select Case Choice
Case Is = "Region"
'Sorting procedure code goes here
Case Is = "District"
'Sorting procedure code goes here
Case Is = "Volume"
'Sorting procedure code goes here
End Select

End Sub
'End Macros

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=553044

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink in menubar Mr BT Excel Worksheet Functions 0 June 7th 06 04:34 AM
Menubar Control itsrobhaines Excel Programming 1 January 20th 06 12:30 PM
Create your own Menubar cassy01 Excel Discussion (Misc queries) 1 September 6th 05 01:03 PM
excel menubar majikman[_26_] Excel Programming 3 May 24th 04 04:13 PM
menubar buttons don't appear Janet[_5_] Excel Programming 1 January 30th 04 07:32 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"