Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    250
    Thanks
    0
    Thanked 0 Times in 0 Posts

    inputting multiple number on an input box

    Hello-I am doing some VBA for excel 2010 and have some questions about how to have user input multiple numbers in an inputbox field. I am using the index(es) to filter a table. Maybe this is not the most efficient way to do this, but I am learning. Basically, I want the user to input one or more indexes and then filter by those index or indexes. Below is the code. Any help would be great. Thank you.
    Code:
    Sub SortbyIndex()
    '
    ' SortbyIndex Macro
    ' Sort by Index
    '
    '
    Dim strgName As String
    strgName = InputBox(prompt:="Index to sort", Title:="Enter Index #")
    If strgName = vbNullString Then
    Exit Sub
    Else
        Range("A1").Select
        Selection.CurrentRegion.Select
          ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$AF$2069"), , xlYes).Name = "Table1"
        Range("Table1[#All]").Select
        ActiveSheet.ListObjects("Table1").Range.AutoFilter field:=3, Criteria1:=strgName
        
            'Array("1780", "1680"), Operator:=xlFilterValues
            Range("B2071").Select
        ActiveCell.FormulaR1C1 = "=SUBTOTAL(3,a2:a2069)"
        Range("A2071").Select
        ActiveCell.FormulaR1C1 = "Total # of Positions"
        Columns("A:A").EntireColumn.AutoFit
        Range("A2071").Select
    End If
    End Sub
    Last edited by RetiredGeek; 2012-11-14 at 19:03. Reason: Added Code Tags

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Sheba,

    When posting code please use code tags, e.g. [code] your code here [/code].
    You'll notice I added them to your post above.
    The reason you can see the tags here is because I enclosed them in "noparse" tags.

    Note: with complex questioins it is always advisable to attach a sample workbook with a before sheet and after sheet so responders can see what you are starting with and where you want to get to.
    Last edited by RetiredGeek; 2012-11-14 at 19:07.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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