시트의 "M"열에 "! UKINADMISSIBLE"에 대한 조회 코드가 있습니다. 목록 상자 (listbox1)에 "! UKINADMISSIBLE"이있는 모든 선택된 행을 표시합니다. 그것은 잘 작동하지만 시트에서 모든 "! UKINADMISSIBLE"을 삭제하면이 코드 줄에서이 오류 (목록 속성, 잘못된 속성 값을 설정할 수 없음)를 제공합니다. --->Me.ListBox1.List = arrLstBox) ---> 오류 누구든지 나를 고칠 수 있습니다.목록 속성을 설정할 수 없습니다. 잘못된 속성 값 오류
Private Sub btnIUK_Click()
Dim arrLstBox()
Dim rng, FoundCell, tmpCell As Range
Dim i, j, numRows, lastColumn, lastRow As Long
Dim FirstAddress, searchFor, colWidth As String
Set rng = ActiveSheet.UsedRange
numRow = 0
With rng
lastRow = .Rows.Count
lastColumn = .Columns.Count
End With
Me.ListBox1.ColumnCount = lastColumn
Me.ListBox1.ColumnWidths = "60;70;190;40;90;90;70;80;50;60;90;120;5"
Set FoundCell = rng.Find(what:="!UKINADMISSIBLE", LookIn:=xlValues, lookat:=xlWhole)
If Not FoundCell Is Nothing Then _
FirstAddress = FoundCell.Address
Do Until FoundCell Is Nothing
Set FoundCell = rng.FindNext(after:=FoundCell)
If FoundCell.Address = FirstAddress Then
numRow = numRow + 1
Exit Do
ElseIf FoundCell.Row <> rng.FindNext(after:=FoundCell).Row Then
numRow = numRow + 1
End If
ReDim arrLstBox(1 To numRow + 1, 1 To lastColumn + 1)
Loop
Do Until FoundCell Is Nothing
For i = 1 To numRow
For j = 1 To lastColumn
If Not IsEmpty(Cells(FoundCell.Row, j).Value) Then
arrLstBox(i, j) = Cells(FoundCell.Row, j).Value
End If
Next j
Set FoundCell = rng.FindNext(after:=FoundCell)
If FoundCell.Address = FirstAddress Then _
Exit For
Next i
If FoundCell.Address = FirstAddress Then _
Exit Do
Loop
Me.ListBox1.List = arrLstBox()----->ERROR
lastRow = ListBox1.ListCount
MsgBox "Records Found = " & lastRow, vb, "Inadmissibles On UK Sectors"
End Subode here
감사로드, 정말 감사. 다시 감사합니다 :) –
Ambie, 정말 시원한 덕분에 –