• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete duplicate

jho78

New Member
Hi

On Sheet1 Cell D2 I have a dropdown where the name can be selected. This then populates the Label1.Caption on a UserForm. I have the UserForm where details are entered and when the 'Continue' command button is clicked the data is saved to a sheet (Sheet2). On clicking the command button on the form I would like to check the sheet where the data goes for duplicates of the Label1.Caption which is copied to Column A of Sheet2 and delete the first instance (entire row) but keep the latest.

Any help would be appreciated.

Thanks
 

Attachments

  • Testbook.xlsm
    20.5 KB · Views: 1
Hi, according to your explanation the UserForm1 module :​
Code:
Private Sub CommandButton1_Click()
          Dim Rf As Range
    With Sheet2.UsedRange.Columns(1).Rows
          Set Rf = .Find(Label1.Caption, , , 1)
    While Not Rf Is Nothing
              Rf.EntireRow.Delete
          Set Rf = .FindNext
    Wend
       .Item(.Count)(2).Resize(, 3).Value2 = Array(Label1.Caption, TextBox1.Text, TextBox2.Text)
       .Parent.Activate
    End With
        Unload Me
End Sub

Private Sub UserForm_Initialize()
    Label1.Caption = Sheet1.[D2].Text
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Back
Top