View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
daphoenix daphoenix is offline
external usenet poster
 
Posts: 18
Default deleting condition after the first duplicate

thanks for such the timly reply..
i tried the first code, and it deletes everything but the first
line(realestate) and the second line.

this is what i start with:

US OE Specialty-Real Estate
SUSIX JPMORGAN U.S. REAL ESTATE A
DJ WILSHIRE REIT TR
MORNINGSTAR RANK

US OE Specialty-Real Estate
MUSDX MORGAN STANLEY INST US REAL ESTATE P
DJ Wilshire REIT TR
MORNINGSTAR RANK

and the result I am looking to get is something like this:

US OE Specialty-Real Estate
SUSIX JPMORGAN U.S. REAL ESTATE A
DJ WILSHIRE REIT TR
MORNINGSTAR RANK

MUSDX MORGAN STANLEY INST US REAL ESTATE P
DJ Wilshire REIT TR
MORNINGSTAR RANK

and if there is a way to keep the formatting of the cells i.e. fill color
that would be a dded bonus....

thanks again for the help



"Don Guillett" wrote:

try this.

Sub deletecattitles()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row - 3 To 1 Step -5
'MsgBox Cells(i, mc)
If Cells(i + 5, mc) = Cells(i, mc) Then
Rows(i + 8).Delete
Rows(i + 7).Delete
Rows(i + 4).Resize(2).Delete
End If
Next i
End Sub

OR to JUST delete the second title and blank row
Sub deletecattitles()
[cpyblk].Copy Range("a1")
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row - 3 To 1 Step -5
'MsgBox Cells(i, mc)
If Cells(i + 5, mc) = Cells(i, mc) Then
'Rows(i + 8).Delete
'Rows(i + 7).Delete
Rows(i + 4).Resize(2).Delete
End If
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"daphoenix" wrote in message
...
I have a spreadshhet that looks up stocks and the information that I want
for
that stock. I am trying to create a grouping. Each stock has a category
and
when it is imported it is labeled with that category. What I am looking to
do
is if there is a way to delate the category name after the forst occurence
looked up. So in the example below after the first US OE
Speacilty-RealEstate
have excel delete just the next occurence heading but leave the other
information that follows. So it is like US OE Speacilty Real Estate is a
group of funds.

US OE Specialty-Real Estate
SUSIX JPMORGAN U.S. REAL ESTATE A
DJ WILSHIRE REIT TR
MORNINGSTAR RANK

US OE Specialty-Real Estate
MUSDX MORGAN STANLEY INST US REAL ESTATE P
DJ Wilshire REIT TR
MORNINGSTAR RANK

US OE Foreign Large Value
CIVVX CAUSEWAY INTERNATIONAL VALUE INV
MSCI EAFE NR USD
MORNINGSTAR RANK

US OE Mid-Cap Value
MLUSX MASSMUTUAL SELECT MID-CAP VALUE S
RUSSELL MID CAP VALUE TR
MORNINGSTAR RANK