Results 1 to 2 of 2
2012-11-14, 14:30 #1
- Join Date
- Dec 2006
- 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.
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
2012-11-14, 19:05 #2
- Join Date
- Mar 2004
- Manning, South Carolina
- Thanked 1,471 Times in 1,339 Posts
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.