sufianmalik
Board Regular
- Joined
- May 7, 2002
- Messages
- 128
hi all
trying to format my spreadsheet.
I have a title in B2 and C2 downwards displays records within this title.
The following section beginning at B10 has more than one title so B10 then B11 then B12 with child values in C12 downwards.
I have a total heading in column A so any procedure can stop at this point.
I am trying to copy the lowest level heading and paste that in the cells below, so B2 heading is copied down until C9 once it recognises a heading in B10 it has to ascertain whether it has a lower heading and if so do nothing with and move down a row. if this is the lowest heading, copy it and paste down each row unitl it reaches the next heading or the minus offset row is TOTAL
Here's what i have so far...
Range("b2").Select
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Offset(-1, 0) = "TOTAL"
If ActiveCell.Value = "" Then ActiveCell.Offset(-1, 0).Copy
ActiveCell.PasteSpecial
ActiveCell.Offset(1, 0).Select
ElseIf ActiveCell.Value <> "" Then ActiveCell.Copy
ActiveCell.Offset(1, 0).PasteSpecial
End If
Loop
can anyone tell me what im doing wrong? i have basic skills and i was tempted to simply copy and paste this code over and over so it will keep running but the number of headings may change which will cause the code to fail!
trying to format my spreadsheet.
I have a title in B2 and C2 downwards displays records within this title.
The following section beginning at B10 has more than one title so B10 then B11 then B12 with child values in C12 downwards.
I have a total heading in column A so any procedure can stop at this point.
I am trying to copy the lowest level heading and paste that in the cells below, so B2 heading is copied down until C9 once it recognises a heading in B10 it has to ascertain whether it has a lower heading and if so do nothing with and move down a row. if this is the lowest heading, copy it and paste down each row unitl it reaches the next heading or the minus offset row is TOTAL
Here's what i have so far...
Range("b2").Select
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Offset(-1, 0) = "TOTAL"
If ActiveCell.Value = "" Then ActiveCell.Offset(-1, 0).Copy
ActiveCell.PasteSpecial
ActiveCell.Offset(1, 0).Select
ElseIf ActiveCell.Value <> "" Then ActiveCell.Copy
ActiveCell.Offset(1, 0).PasteSpecial
End If
Loop
can anyone tell me what im doing wrong? i have basic skills and i was tempted to simply copy and paste this code over and over so it will keep running but the number of headings may change which will cause the code to fail!