Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Delete rows based on a userform textbox value Excel 2010

$
0
0

Hello all, this seems simple but can't figure it out, I want to delete rows on sheets 2 and 3 that match my textbox value. The code below works on sheet 3 if I replace "Me.txtProbOppTblID.Value" with a ID number like "If rng.Cells(i).Value = 2". It's a one too many relationship. So for each problem there can be many objectives.  So what I want is if the user deletes the problem all related objectives go with.

Private Sub CommandButton1_Click()
   Dim rng As Range, i As Integer
        'Set the range to evaluate to rng.
   Set rng = Sheets(3).Range("H2:H5")
        'Loop backwards through the rows
       'in the range that you want to evaluate.
     For i = rng.Rows.Count To 1 Step -1
            
  If rng.Cells(i).Value = Me.txtProbOppTblID.Value Then rng.Cells(i).EntireRow.Delete
       Next
  
End Sub

Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>