Input Box data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blues7709
    New Member
    • Sep 2009
    • 2

    Input Box data

    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]
    Last edited by debasisdas; Sep 15 '09, 07:35 AM. Reason: formatted by adding code tags
  • smartchap
    New Member
    • Dec 2007
    • 236

    #2
    Not gone through ur program but it seems that u want to enter multiple IDs in InputBox and do calculations, etc on individual ID. Here are my suggestion:
    You can get multiple IDs in InputBox separated by a comma (,). Suppose u get:
    Code:
    a=InputBox("Please enter IDs separated by comma")
    Now use another variable, say 'ID', in which u separate these ID from a one by one using Instr function (inside a loop) and do ur calculation, etc for each ID.

    Comment

    • blues7709
      New Member
      • Sep 2009
      • 2

      #3
      Thanks very much for your help. I will try this and see if it works.

      Comment

      • kadghar
        Recognized Expert Top Contributor
        • Apr 2007
        • 1302

        #4
        Originally posted by smartchap
        ...

        Now use another variable, say 'ID', in which u separate these ID from a one by one using Instr function (inside a loop) and do ur calculation, etc for each ID.
        Or using the SPLIT function, of course ^.^

        Comment

        • smartchap
          New Member
          • Dec 2007
          • 236

          #5
          Yes using Instr function will require aloop & a little bit of code inside loop. With Split function it is straight forward. I agree with kadghar. Posting ur query to such forums is beneficial that u get a lot of solutions & u can choose the best among them.

          Comment

          Working...