Beneindias
Board Regular
- Joined
- Jun 21, 2022
- Messages
- 120
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi guys,
I have a file where I have an inputbox, where the user types "MyInputMatriculaMaiusculas" values.
This variable is then used to o through a table and delete the row, where this value is in the second column.
Or, at least, that was the goal, because, in reality, this code is doing nothing..
can anybody help me?
This code is suposed to go to "Tabelas Apoio" sheet, and go to "Viaturas" table, look for the number plate in the second column of said table and then, delete that same row.
What am I doing wrong here?
First tried this solution, but it didn't work too:
I have a file where I have an inputbox, where the user types "MyInputMatriculaMaiusculas" values.
This variable is then used to o through a table and delete the row, where this value is in the second column.
Or, at least, that was the goal, because, in reality, this code is doing nothing..
can anybody help me?
This code is suposed to go to "Tabelas Apoio" sheet, and go to "Viaturas" table, look for the number plate in the second column of said table and then, delete that same row.
What am I doing wrong here?
VBA Code:
Dim tblA As ListObject
Dim a As Long
Set tblA = Worksheets("Tabelas Apoio").ListObjects("Viaturas")
For a = tblA.ListRows.Count To 1 Step -1
If tblA.DataBodyRange(a, 2) = MyInputMatriculaMaiusculas Then
tblA.ListRows(a).Delete
End If
Next a
First tried this solution, but it didn't work too:
VBA Code:
For a = Worksheets("Tabelas Apoio").ListObjects("Viaturas").ListRows.Count To 1 Step -1
If Cells(a, 2).Value = MyInputMatriculaMaiusculas Then
Cells(a, 2).EntireRow.Delete
End If
Next a