Line deletion based on a cell from another worksheet

amertin Posted messages 15 Status Member -  
lolomusic667 Posted messages 2527 Status Member -
Hello,

I want, among other things, to delete the row in a database where the reference in column A matches the value indicated in my search tab cell (variable in A1, for example). I can't get the correct syntax, as I am a VBA beginner.

In short, I have a client record that I want to update. To do that, I created the code that will allow me to add the new row, but I can't get the one that would delete the existing corresponding row first...

Thank you for your help!

1 answer

  1. lolomusic667 Posted messages 2527 Status Member 11
     
    Hello,

    Try data menu, delete duplicates.

    Does that meet your needs and does it work?
    -1
    1. amertin Posted messages 15 Status Member
       
      No, actually it’s a “everything” with other VBA functions. So I need the VBA code that will allow me to delete the corresponding row. Thanks anyway!
      0
      1. lolomusic667 Posted messages 2527 Status Member 11 > amertin Posted messages 15 Status Member
         
        You have to start from the bottom in the loop

        Sub DeleteLine()
        Dim i%
        For i = 200 To 5 Step -1
        If Cells(i, 5).Value <> "RSHOP" Then Rows(i).EntireRow.Delete
        Next i
        End Sub

        Does that work?
        0
    2. amertin Posted messages 15 Status Member
       
      Can you tell me how I should integrate my variables in the code, especially the cell where the reference number is located? I don’t understand why there is "for i=200" ? Thanks for the explanations...!
      0
      1. lolomusic667 Posted messages 2527 Status Member 11 > amertin Posted messages 15 Status Member
         
        It is English. For means for in English. In short, for each cell. The rest is the VBA code.
        0