0
사용자는 확인란을 사용하여 원하는 옵션을 선택합니다. 각 확인란의 캡션 값은 동적 배열에 저장되고 메시지 상자에 표시되어 선택을 확인합니다.동적 배열 (VBA)의 값을 통한 검색
cell (x, 4)가 배열의 값과 같은지 확인하는 모든 행에서 셀 범위를 반복해야하지만 그와 같은 루프를 수행하는 방법을 모르겠습니다. 아래 코드에서 배열이 채워지는 위치를 확인하십시오.
미리 감사드립니다.
Sub ProcessStrats_Click()
Dim ctl As Control
Dim cnt As Long
Dim msg As String
Dim i As Long
Dim cResp As Integer
Dim stArray() As Variant
cnt = 0 'Initialize counter outside of loop
For Each ctl In StratFill.Controls 'look at every control in StratForm box
If Left(ctl.Name, 8) = "CheckBox" Then 'if the control is named 'checkbox' then
If ctl.Value = True Then 'if the control is marked as 'true' i.e. checked, then
ReDim Preserve stArray(0 To cnt) 'Reset the array dimension on each iteration of loop
stArray(cnt) = ctl.Caption 'Add value in value of checkbox caption to Array
cnt = cnt + 1 'Advance the counter to next array item
End If
End If
Next
Unload StratFill 'unload and close stratfill form
msg = "The following strategies will be priced:" & vbNewLine & vbNewLine
For i = LBound(stArray) To UBound(stArray) 'loops through all values of array
msg = msg & stArray(i) & vbCR 'strings together displayed txt
Next i
If MsgBox(msg, vbYesNo, "Confirm Strategies") = vbYes Then
'if yes is clicked
Call RunPricing '"RunPricing" will run
Else 'if no is clicked
StratFill.Show 'then the strategy selector box will display again
End If
을 오히려 메시지에 표시보다는 일치 할 각 하나에 대한 경우 프로세스를 시작 표시하는 방법이있다 배열의 값? – EmsBish
원래 질문에 @emsbish : msg = stArray (i) & vbCR '문자열이 함께 표시됩니다. txt' 참조에서 찾은 값에 대해 프로세스를 실행할 수 있습니다. ActiveCell.Value 또는 .Range. 'msg = msg' 문장 만 바꾸면됩니다. –