Delete Row If OracleID = Value
Connie started with a Private button event code, I just adapted it, so I
think that would not be the problem.
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"kounoike" wrote in message
...
you seem to copy Bob's code to Worksheet module. if that is the case, i
think Bob's code would not work as it is, but needs some modifications. i
think a simple way is to copy Bob's code to a standard module and remove
"Private" from Sub statement and call it from your button like below. but
i'm not sure this willl work and way to go.
Private Sub CommandButton1_Click() '<<==Change to your button name
Check_For_Existing_Oracle_No_Click
End Sub
Sub Check_For_Existing_Oracle_No_Click()
Dim iLastRow As Long
Dim rng As Range
Worksheets("Upload Data").Select
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("C1:C" & iLastRow)
rng.AutoFilter
rng.AutoFilter field:=1, Criteria1:=Range("oracle_no").Value
Set rng = Range("C2:C" & iLastRow).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
Range("C1").AutoFilter
End Sub
keizi
"Connie" wrote in message
oups.com...
Thanks for your help. I'm still not able to get this to work. The
ilastrow returns a value which is not the last row in the range. Also,
a delete takes place, but it takes place from the sheet from which the
command button was called, and not the "Upload Data" sheet.
Help!
Here's the data I'm using. Should I not expect ilastrow to equal 29?
Also, what does Cells(Rows.Count, "A") mean? Thanks again.
kounoike wrote:
Sorry, my if clause never happen in your code.
"kounoike" wrote in message
...
Well, I understand, if the lastrow is in autofilter range.
keizi
"Bob Phillips" wrote in message
...
It is. Couldn't have had a problem in the tests as it just extended
the
range to 2 & iLastRow, so if iLastrow was 72, it would set it to
272,
not
a
problem, just a waste.
--
HTH
|