0
설정 범위에서 단일 열의 행을 반복하려고합니다. 범위를 WorkingRange로 설정 한 다음 SystemCol로 원하는 열을 설정합니다. 어떻게 각 열을 설정 열에 루프합니까? 선택한 열에서 값이있는 각 행에 대한 메시지 상자를 표시하려고합니다. **가있는 코드의 영역은 코드를 삽입하려고하는 곳이지만 전체 셀은 단일 셀 주소가 아닌 전체 열 주소입니다.설정 범위에서 단일 열의 행을 반복합니다.
'===============================================================================================
'Description: Loops through the selected site and adds in the vulnerability totals for each _
systems
'Originally written by: Troy Pilewski
'Date: 2016-06-30
'===============================================================================================
'Declares variables
Dim ToWorkbook As Workbook, FromWorkbook As Workbook
Dim ToWorksheet As Worksheet, FromWorkSheet As Worksheet
Dim WorkingRange As Range, WholeRange As Range
Dim FromWorkbookVarient As Variant, ShipNameList() As Variant
Dim TitleString As String, FilterName As String, CurrentSystemName As String, _
ShipNames() As String, SelectedShipName As String
Dim LastRow As Long, ShipRow As Long
Dim StartRow As Integer
Const RowMultiplyer As Integer = 47
'-----------------------------------------------------------------------------------------------
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set ToWorkbook = ActiveWorkbook
Set ToWorksheet = ToWorkbook.ActiveSheet
LastRow = ToWorksheet.Range("Y:Y").Find(_
What:="*", _
After:=ToWorksheet.Range("Y1"), _
LookAt:=xlByRows, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious _
).Row
'MsgBox _
' Prompt:="Y1:Y" & LastRow, _
' Title:="Ship Range"
ShipNameList = ToWorksheet.Range("Y1:Y" & LastRow).Value
For Each Item In ShipNameList
Dim BoundCounter As Integer
If Left(Item, 3) = "USS" Then
BoundCounter = BoundCounter + 1
End If
Next Item
ReDim ShipNames(BoundCounter - 1)
BoundCounter = 0
For Each Item In ShipNameList
If Left(Item, 3) = "USS" Then
ShipNames(BoundCounter) = Item
' Debug.Print ShipNames(BoundCounter)
BoundCounter = BoundCoutner + 1
Else
' Debug.Print UBound(ShipNames())
Exit For
End If
Next Item
TitleString = "Select a ship..."
SelectedShipName = GetChoiceFromChooserForm(ShipNames, TitleString)
If SelectedShipName = "" Then
Exit Sub
End If
ShipRow = ToWorksheet.Range("Y:Y").Find(_
What:=SelectedShipName, _
After:=ToWorksheet.Range("Y1"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True _
).Row
'Debug.Print ShipRow
StartRow = 14
If ShipRow > 1 Then
StartRow = (RowMultiplyer * (ShipRow - 1)) + StartRow
Else
StartRow = 14
End If
Set WorkingRange = ToWorksheet.Range("B" & StartRow & ":G" & StartRow + 38)
Set SystemCol = WorkingRange.Columns(2)
'Debug.Print WorkingRange.Address
FilterName = "Excel Files (*.xls), *.xls,Excel Files (*.xlsx), *.xlsx,All Files (*.*), *.*"
TitleString = "Scan File Selection"
**For Each rw In SystemCol
Debug.Print rw.Address
Next rw**
고맙습니다! 당신의 대답은 완벽하게 작동합니다. – TroyPilewski
제한 시간에 도달하면 알려드립니다. – TroyPilewski