Does anyone know how to do advanced input box functions? I am trying to use 1 input box to capture the users requests for several ID numbers. I then take these ID's and compare them to an Excel column and hide all the things that don't match these ID's. It works perfectly for a single entry. Not sure how to do multiple entries.
Here is my code.
[code=vb]
Sub Enrollments()
Dim rownumber As Integer, intLastRow As Integer, mycell As Integer, mycolor As Integer, startcell As Integer, X As Integer, Y As Integer, Z As Integer, A As Integer, myvar As Integer, columnnumber As Integer
Range("C1").Sel ect
intLastRow = ActiveCell.Curr entRegion.Rows. Count
x1 = ActiveWorkbook. Name
Y = 6
Z = 4
A = 5
startcell = 2
myvar = 2
columnnumber = 8
rownumber = 2
Columns("G:G"). Select
Selection.TextT oColumns Destination:=Ra nge("G1"), DataType:=xlDel imited, _
TextQualifier:= xlDoubleQuote, ConsecutiveDeli miter:=False, Tab:=True, _
Semicolon:=Fals e, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNu mbers:=True
Columns(columnn umber).Select
Selection.Inser t shift:=xlToRigh t
X = InputBox("Pleas e enter the BPL numbers.", "BPL InputBox ")
Cells(myvar, columnnumber).S elect
intLastRow = intLastRow + 1
Do Until myvar = intLastRow
ActiveCell.Form ulaR1C1 = "=if(RC[-1]=" & X & ",""MATCH"",""N O MATCH"")"
If ActiveCell <> "MATCH" Then
Rows(rownumber) .Select
Selection.Entir eRow.Hidden = True
End If
ActiveCell.Offs et(1, 0).Select
If myvar = intLastRow Then
End If
myvar = myvar + 1
rownumber = rownumber + 1
Cells(myvar, columnnumber).S elect
Loop
columnnumber = 16
myvar = 2
Cells(myvar, columnnumber).S elect
ActiveCell.Form ulaR1C1 = "=CONCATENATE(R C[-12],RC[-11],RC[-9])"
Range("P2").Sel ect
Selection.AutoF ill Destination:=Ra nge("P2", "P" & intLastRow)
Cells(myvar, columnnumber + 1).Select
'Counting for duplicates
ActiveCell.Form ulaR1C1 = "=COUNTIF(R C[-1]:R[" & intLastRow & "]C[-1],RC[-1])"
Range("Q2").Sel ect
Selection.AutoF ill Destination:=Ra nge("Q2", "Q" & intLastRow)
Cells(myvar, columnnumber + 1).Select
myvar = 2
Cells(myvar, columnnumber + 1).Select
Do Until myvar = intLastRow
If ActiveCell <> 1 Then
Selection.Inter ior.ColorIndex = 3
End If
ActiveCell.Offs et(1, 0).Select
If myvar = intLastRow Then
End If
myvar = myvar + 1
Loop
myCount = 0
mycolor = 3
For I = startcell To intLastRow
mycell = Cells(I, columnnumber + 1).Interior.Col orIndex
If mycell = mycolor Then
myCount = 1 + myCount
End If
Next I
Worksheets("Exp ort Worksheet").Cel ls(intLastRow, columnnumber + 1).Value = myCount
Worksheets("Exp ort Worksheet").Cel ls(intLastRow, columnnumber).S elect
MsgBox "All Checks have been completed.", vbInformation, "Enrollment s"
End Sub[/code]
Here is my code.
[code=vb]
Sub Enrollments()
Dim rownumber As Integer, intLastRow As Integer, mycell As Integer, mycolor As Integer, startcell As Integer, X As Integer, Y As Integer, Z As Integer, A As Integer, myvar As Integer, columnnumber As Integer
Range("C1").Sel ect
intLastRow = ActiveCell.Curr entRegion.Rows. Count
x1 = ActiveWorkbook. Name
Y = 6
Z = 4
A = 5
startcell = 2
myvar = 2
columnnumber = 8
rownumber = 2
Columns("G:G"). Select
Selection.TextT oColumns Destination:=Ra nge("G1"), DataType:=xlDel imited, _
TextQualifier:= xlDoubleQuote, ConsecutiveDeli miter:=False, Tab:=True, _
Semicolon:=Fals e, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNu mbers:=True
Columns(columnn umber).Select
Selection.Inser t shift:=xlToRigh t
X = InputBox("Pleas e enter the BPL numbers.", "BPL InputBox ")
Cells(myvar, columnnumber).S elect
intLastRow = intLastRow + 1
Do Until myvar = intLastRow
ActiveCell.Form ulaR1C1 = "=if(RC[-1]=" & X & ",""MATCH"",""N O MATCH"")"
If ActiveCell <> "MATCH" Then
Rows(rownumber) .Select
Selection.Entir eRow.Hidden = True
End If
ActiveCell.Offs et(1, 0).Select
If myvar = intLastRow Then
End If
myvar = myvar + 1
rownumber = rownumber + 1
Cells(myvar, columnnumber).S elect
Loop
columnnumber = 16
myvar = 2
Cells(myvar, columnnumber).S elect
ActiveCell.Form ulaR1C1 = "=CONCATENATE(R C[-12],RC[-11],RC[-9])"
Range("P2").Sel ect
Selection.AutoF ill Destination:=Ra nge("P2", "P" & intLastRow)
Cells(myvar, columnnumber + 1).Select
'Counting for duplicates
ActiveCell.Form ulaR1C1 = "=COUNTIF(R C[-1]:R[" & intLastRow & "]C[-1],RC[-1])"
Range("Q2").Sel ect
Selection.AutoF ill Destination:=Ra nge("Q2", "Q" & intLastRow)
Cells(myvar, columnnumber + 1).Select
myvar = 2
Cells(myvar, columnnumber + 1).Select
Do Until myvar = intLastRow
If ActiveCell <> 1 Then
Selection.Inter ior.ColorIndex = 3
End If
ActiveCell.Offs et(1, 0).Select
If myvar = intLastRow Then
End If
myvar = myvar + 1
Loop
myCount = 0
mycolor = 3
For I = startcell To intLastRow
mycell = Cells(I, columnnumber + 1).Interior.Col orIndex
If mycell = mycolor Then
myCount = 1 + myCount
End If
Next I
Worksheets("Exp ort Worksheet").Cel ls(intLastRow, columnnumber + 1).Value = myCount
Worksheets("Exp ort Worksheet").Cel ls(intLastRow, columnnumber).S elect
MsgBox "All Checks have been completed.", vbInformation, "Enrollment s"
End Sub[/code]
Comment