Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use Macro to select defined Database (2000 sp3)

    All,
    I have a spreadsheet where I have a defined a database range. As the file grows, I want to have a macro (or VB) for the user to allow sorting based upon specific columns. I could insert the data into the existing VB information I already have and have a new button to call the routine.

    Hans,
    This is a continuation of prior help from you.
    Option Explicit

    Private Sub Workbook_Activate()
    On Error Resume Next
    Application.CommandBars("ARA Metrics").Visible = True
    Worksheets("Workbook Contents Page").Activate

    End Sub

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    Application.CommandBars("ARA Metrics").Delete
    End Sub

    Private Sub Workbook_Deactivate()
    On Error Resume Next
    Application.CommandBars("ARA Metrics").Visible = False
    End Sub

    Private Sub Workbook_Open()

    Dim cbr As CommandBar
    Dim cbb As CommandBarButton
    Set cbr = Application.CommandBars.Add("ARA Metrics")
    'cbr.Top = 72
    'cbr.Left = 780
    cbr.Position = msoBarTop
    'cbr.Position = msoBarRight
    Set cbb = cbr.Controls.Add(msoControlButton)
    With cbb
    .Caption = "ARA Metrics"
    .OnAction = "Select_Form"
    .Style = msoButtonIconAndCaption
    .FaceId = 2950
    End With
    Set cbb = Nothing
    Set cbr = Nothing
    End Sub

    EXISTING VB.


    thanks in advance,
    Brad

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Use Macro to select defined Database (2000 sp3)

    The code you posted is for adding menus. It has nothing to do with sorting.

    What is the sorting macro?
    What is the named range for the database?
    What is/are the specific columns you want to sort by?

    Steve

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use Macro to select defined Database (2000 sp3)

    Steve,
    I posted the existing code, because Hans helped me during the last few weeks. I would like this to be a sub of the existing code. The name defined is database. It expands as I use the 'form' utility bulit into excel. The users will be sorting the entire database on column 'C'. From that, I can expand other routines as needed. I just need to have a template to go by for the first sort. I do not have a sort as of yet. I am hoping th get help on developing the code. I do not understand how to call the defined database in code.

    Thanks,,
    Brad

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use Macro to select defined Database (2000 sp3)

    Is this what you need?

    <pre>Public Sub SortDB()
    Range("database").Sort Key1:=Range("C1"), Order1:=xlAscending
    End Sub
    </pre>

    Legare Coleman

  5. #5
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use Macro to select defined Database (2000 sp3)

    Legare ,
    I will give it a shot and see what happens...

    Thank,s
    Brad

  6. #6
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use Macro to select defined Database (2000 sp3)

    Legare,
    Thanks for the help on this one. Worked fine.

    Thanks again,
    Brad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •