Thread: Chapters???
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Pluggie Pluggie is offline
external usenet poster
 
Posts: 23
Default Chapters???

And did you find a solution?

"Jacob Skaria" wrote:

Try the below macro with your data in Cols A.B.C

Sub MyMacro()
Dim lngRow As Long, strChapter As String
lngRow = 2
Do While Trim(Range("A" & lngRow)) & _
Trim(Range("B" & lngRow)) & Trim(Range("C" & lngRow)) < ""

If Trim(Range("A" & lngRow)) < "" Then _
strChapter = Trim(Range("A" & lngRow))

If Trim(Range("B" & lngRow)) = "" Then _
Rows(lngRow).Delete

If Trim(Range("A" & lngRow)) = "" Then _
Range("A" & lngRow) = strChapter
lngRow = lngRow + 1
Loop
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pluggie" wrote:

Hello,

I have a list with names (B):

The layout is as follows:
chapters (column A), names (B), age (C).

The names (B) and corresponding ages (C) are devided into chapters.

Example:
Chapter Name Age
Family
Pete 25
Gill 23
Janet 44
Friends
Gemma 32
Vincent 33
Eric 32
Vicky 30
Lennart 35
John 33

Now...
I want a macro that copy-pastes the chapternames in front of each name in
that chapter and to delete the lines this data came from.
So the output will look like this:

Chapter Name Age
Family Pete 25
Family Gill 23
Family Janet 44
Friends Gemma 32
Friends Vincent 33
Friends Eric 32
Friends Vicky 30
Friends Lennart 35
Friends John 33

There are more chapters and all groups in these chapters vary in length.

Who can help me?