Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50190

LBound(Name) to UBound(Name) Multiple Arrays

$
0
0
Greetings

I have a code that works perfectly by searching an array and by displaying the results. As well as the interactions with window pane messages as seen below

Code:

Dim Qs As String
        Dim i As Integer
        Dim myAry

              myAry = Array("0003/3857/0000", "0101/3857/0000", "0201/3857/0000", "0301/3857/0000", "0401/3857/0000", _
                "0550/3857/0000", "0601/3857/0000", "0700/3857/0000", "0003/6063/0000", "0101/6063/0000", "0201/6063/0000", _
                "0301/6063/0000", "0401/6063/0000", "0550/6063/0000", "0601/6063/0000", "0700/6063/0000")
            For i = LBound(myAry) To UBound(myAry)
            If Range("B" & RowNumbr) = myAry(i) Then
                Qs = MsgBox("The current vote you created is allocated on Vehicle. Is This Correct?", _
                    vbYesNo + vbQuestion, "VALIDATE")
                If Qs = vbNo Then
                    Range("C" & RowNumbr) = "No"
            ElseIf Qs = vbYes Then
            Range("C" & RowNumbr) = "Yes"
        End If
    Exit For
End If
    If i = UBound(myAry) Then MsgBox "Vote Number Not found", vbCritical, "WARNING"
Next

However, i would like to add the following arrays:

Code:

PumpO = Array("0101/4233/0000", "0301/4233/0000", "0401/4233/0000", _
                "0403/4233/0000", "0515/4233/0000", "0550/4233/0000", "0813/4233/0000") 'Pump Operators
       
        ST = Array("0101/4525/0000", "0201/4525/0000", "0301/4525/0000", _
                "0401/4525/0000", "0550/4525/0000", "0601/4525/0000", "0700/4525/0000", _
                "0211/4525/0000", "0403/4525/0000", "0501/4525/0000", "0515/4525/0000") 'S & T
       
        SALGA = Array("0301/4535/0000", "0550/4535/0000") 'Salga
       
        Sec = Array("0301/4213/0000", "0550/4213/0000", "0700/4213/0000")
       
        TarW = Array("0101/4515/0000", "0401/4515/0000") 'Target Women
       
        TarY = Array("0003/4517/0000", "0401/4517/0000") 'Target Youth
       
        Train = Array("0211/4523/0000", "0501/4523/0000") 'Training

to this code so that it searches these arrays and only the if there is no positive match, it will give me the error as entered in the first code.
I have been at this for a week, and can not get it right, Im very new to programming.

Much Thanx
Sufboard

Viewing all articles
Browse latest Browse all 50190

Trending Articles