1
I’m having a very specific question. I hope you can help me
I have a spreadsheet that contains a table called "Activities". I have some form controls to fill the same but I emerged the need to insert and delete rows from this table without interfering with the cells next to it. Filling a new row of the table without affecting the cells on the side is no problem, I’ve already done that. The problem is to delete the column row that contains the added value (only the last one). Follow images to illustrate what I intend to do.
By clicking on the + button of "Answered Phone Calls", it adds a row in the "Activities" table with the text "Phone Service".
I wish I could do the same thing with the button less, when clicking on it, the last line containing "Phone Service" is deleted (only the last one inside the table), but in a way not to interfere with the cells with the rectangle in blue.
Is there a way? As you can see, I already have a control that can delete the last row of the table, I use this code to do this:
Private Sub RemoveLinha_Click()
Dim i As Integer
i = ActiveSheet.ListObjects("Atividades").Range.Rows.Count
If i > 2 Then
Range("D" & i).ListObject.ListRows(i - 1).Delete
End If
End Sub
However, I don’t know how to identify only the last value containing the specific text for each button unless I add.
Daniel, there is no person more enlightened than you! Thank you very much, from the heart! That’s exactly what I was trying to do, I guess I just wasn’t seeing where I was going wrong anymore! I broke my head for 2 weeks because of this haha! And I did not understand why my logic was wrong! I got to the loop part, and I found the texts, but the code erased all the lines that contained the text, not just the last! Now Oce taught me how to do and I will be eternally grateful! Hugs!
– Alessandro Boncompagni
Please read How and why to accept an answer?
– danieltakeshi