Tenho uma planilha dinâmica aqui que gostaria de exibir apenas na caixa de listagem, colunas de A a F com coluna A/Nome diferente de célula nula/vazia.
UM | B | C | E | E | F |
---|---|---|---|---|---|
Nome | Pontuação | Complexidade | Pontos | Total com pontos | Total sem pontos |
Tom | 5 | 3 | 0,25 | 105,00% | 100,00% |
Brenda | 5 | 4 | 0,5 | 110,00% | 100,00% |
Marca | 5 | - | #VALOR! | #VALOR! | |
- | #VALOR! | #VALOR! | |||
- | #VALOR! | #VALOR! |
Tentei isso abaixo durante a inicialização:
Sub forListBoxShow()
Dim ws As Worksheet, colList As Collection
Dim arrData, arrList, i As Long, j As Long
Set colList = New Collection
Set ws = Worksheets("Sheet1")
arrData = ws.Range("A1:F" & ws.Cells(ws.Rows.count, "A").End(xlUp).Row)
' build collection of row numbers
For i = 2 To UBound(arrData)
If arrData(i, 1) <> vbNullString Then
colList.Add i, CStr(i)
End If
Next
ReDim arrList(1 To colList.count + 1, 1 To UBound(arrData))
For j = 1 To 6
arrList(1, j) = arrData(1, j) ' header
For i = 1 To colList.count
arrList(i + 1, j) = arrData(colList(i), j)
Next
Next
listBoxShow.Clear
With Me.listBoxShow
.ColumnCount = UBound(arrData, 2)
.ColumnWidths = "50,50,70,40,90,90"
.list = arrList
End With
End Sub
Mas estou recebendo subscript out of range
erro. Também tentei adicionar valores reais a células que têm #VALUE!
como Nome, "Mark", mas tenho o mesmo erro. (Para células com #VALUE! - tem fórmula padrão e tem propósito). Também tentei isso para o código acima, mas tenho o mesmo erro:
If Not arrData(i, 1) = "" Then
Agradeço sua ajuda.