delete based on

G

Guest

I have a list
where fields organisation and position
In the position the fields are either CC (chairman), CT (treasures) and CS
(secretary)

what if want is a macro to look up the list. and if the chairman field is
there, then delete row CT aND CS
and if CC is not there then keep either CT and if CT is not there then keep
CS
 
C

Chip Pearson

Try some VBA code like the following:


Dim CCRng As Range
Dim CTRng As Range
Dim CSRng As Range

Set CCRng = Range("A:A").Find(what:="CC", lookat:=xlWhole,
LookIn:=xlValues)
If Not CCRng Is Nothing Then
Set CTRng = Range("A:A").Find(what:="CT", lookat:=xlWhole,
LookIn:=xlValues)
If Not CTRng Is Nothing Then
CTRng.EntireRow.Delete
End If
Set CSRng = Range("A:A").Find(what:="CS", lookat:=xlWhole,
LookIn:=xlValues)
If Not CSRng Is Nothing Then
CSRng.EntireRow.Delete
End If
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top