help, i'm getting confused

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!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
why don't the if statements work?

Sub New_attempt()

Do Until ActiveCell.Offset(-1, 0).Value = "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

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top