0

データの 1 列の条件、つまり範囲修飾をチェックするコードが必要です。それらが範囲に行く必要がある場合、値は「REQ」になり、そうでない場合、値は「E」、「S」、「M」、および「NR」になります。【セレクトケース】で状態を確認しております。選択したケースの開始時に、このエラーが発生します。

販売参照を正しく作成しているかどうかはわかりません。配列に別の列の名前が入力された後、配列から空の要素を調べて削除し、配列のすべての要素を msgbox に表示します。以下は私が使用したコードです:

'Declares total number of personnel as integer
    Dim total As Integer
    total = Worksheets("MASTER").Range("C4").Value

'Declares single element array with personnel full names
ReDim names(total) As String
'Loops through the array checking to see if personnel have qualified on the Rifle Range
For i = (1 + 6) To (total + 6)
    Select Case Worksheets("MASTER").Range(Cells(i, 23)).Text
        Case "REQ"
            names(i - 6) = Worksheets("MASTER").Range(Cells(i, 7)).Value
        Case "NR"
            names(i - 6) = vbNullString
        Case "E"
            names(i - 6) = vbNullString
        Case "S"
            names(i - 6) = vbNullString
        Case "M"
            names(i - 6) = vbNullString
        End Select
Next
'Declares a new array to remove blank elements from the orignal array
ReDim msgnames(LBound(names) To UBound(names))
'Loops through new array removing empty elements
For i = LBound(names) To UBound(names)
    If names(i) <> vbNullString Then
        x = x + 1
        msgnames(x) = names(i)
    End If
Next
'Displays every element of the array
For i = LBound(msgnames) To UBound(msgnames)
    msg = msg & msgnames(i) & vbNewLine
Next
'Declares COMP, NOTCOMP, REQ and NOTREQ variables
Dim COMP As String
Dim NOTCOMP As String
Dim REQ As String
Dim NOTREQ As String
'Adds a comment to the bottom of the Message Box
MsgBox msg, vbOKOnly, "Rifle Range"`
4

1 に答える 1