View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Help with inserting a blank line on condition

Sub separategroups()
Dim lastrow as long, i as long
lastrow = cells(rows.count,1).end(xlup).row
for i = lastrow to 2 step -1
if cells(i,1).value < cells(i -1,1).value then
rows(i).Insert
end if
Next
End Sub

--
Regards,
Tom Ogilvy


"microsatellite" wrote in message
.com...
Hi,

I've been programming in other languages but am very new to VB and still
getting used to its syntax style - so I'm stuck with the simplest of
problems.

What I have is an excel spreadsheet (obviously). In column A there are
text strings (names) that have been sorted into groups. So basically
groups of names down the column. All I want to do is add a complete blank
row after each name group - the number of names in each group is not
consistent.

eg

Peter
Peter
Peter

Paul
Paul

Mary
Mary
Mary
Mary

Can someone provide some help here?

Thanks