View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Norman Jones
 
Posts: n/a
Default delete rows-macro

Hi Tungana,

Try:
'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rcell As Range
Dim delRng As Range
Dim LRow As Long
Dim CalcMode As Long
Const sStr As String = "manager" '<<===== CHANGE

Set WB = ActiveWorkbook '<<===== CHANGE
Set SH = WB.Sheets("Sheet1") '<<===== CHANGE

LRow = Cells(Rows.Count, "B").End(xlUp).Row

Set rng = SH.Range("B1").Resize(LRow)

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

For Each rcell In rng.Cells
If LCase(rcell.Value) = LCase(sStr) Then
If delRng Is Nothing Then
Set delRng = rcell
Else
Set delRng = Union(rcell, delRng)
End If
End If
Next rcell

If Not delRng Is Nothing Then
delRng.EntireRow.Delete
Else
'nothing found, do nothing
End If

With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With

End Sub
'<<=============

---
Regards,
Norman


"TUNGANA KURMA RAJU" wrote in
message ...
I am looking for a macro,that checks a value in a w/sheet range B:B ,if
found,delete the row.
Example:
col a-----------------------col b-----------------------colc
john-----------------------manager------------------$500
lucy------------------------supervisor-----------------$250
cathy----------------------manager-------------------$650
Ibrahim-------------------supervisor------------------$325
david----------------------worker----------------------$200
macro should check,suppose a value in b:b 'manager' ,if I run macro,the
list
will be
Col a----------------------col b-------------------------col c
lucy------------------------supervisor-----------------$250
Ibrahim-------------------supervisor------------------$325
david----------------------worker----------------------$200