Como evitar erro "Invalid Row Index"?
Nesta rotina abaixo, ele me exclui as linhas, mas acaba se perdendo no final e exclui linha que não podia, enfim linhas que tem STATUS permitidos para exibição: OK, SOK, R, ER
O objetivo da rotina é apagar todas as linhas que tenham os STATUS escritos no IF.
Algum outro jeito de fazer isto sem usar laço FOR...NEXT ?
Citação: Public Sub ApagarLinhas()
On Error GoTo erro:
Dim lrow As Long
Dim lColStatus As Long
lColStatus = m_frm.Grid.ColumnIndex("STATUS")
For lrow = 1 To m_frm.Grid.Rows
If m_frm.Grid.CellText(lrow, lColStatus) = "C" Or m_frm.Grid.CellText(lrow, lColStatus) = "SC" Or m_frm.Grid.CellText(lrow, lColStatus) = "CX" Or m_frm.Grid.CellText(lrow, lColStatus) = "TC" Or m_frm.Grid.CellText(lrow, lColStatus) = "G" Or m_frm.Grid.CellText(lrow, lColStatus) = "TX" Or _
m_frm.Grid.CellText(lrow, lColStatus) = "CP" Or m_frm.Grid.CellText(lrow, lColStatus) = "E" Or m_frm.Grid.CellText(lrow, lColStatus) = "EX" Then
Call m_frm.Grid.RemoveRow(lrow)
End If
Next lrow
Exit Sub
erro:
Debug.Print Err.Description
End Sub
Muito obrigado.