help please

sufianmalik

Board Regular
Joined
May 7, 2002
Messages
128
i'm stuck.

column C contains a record and column B contains Sub headngs only i want the sub headings to be copied and next to each record in column C

for example
B1 Sub title
B2 - B38 are empty

C2-C38 have records. I would like a macro to copy B1 and paste to B2-B38

Then

B39 Contains a new heading
B40-B45 are empty

C40-C45 contain records. So it has to copy B39 into B40-B45

There are several other headings that need copying in the same way with differing numbers of records

Is there a quick way of doing this?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try

Code:
Sub fillem()
Dim LR As Long
LR = Range("C" & Rows.Count).End(xlUp).Row
With Range("B1:B" & LR)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
End With
End Sub
 
Upvote 0
thanks for your reply that came up with a debug error on the specialcells row

i'm a basic vba user so don't know what to do to fix!
 
Upvote 0
i had to do something a little more basic and came up with the following:

i know that B8 is the first title but i don't know how far down it should go before it gets to the next title and would therefore have to copy this new value until blank. the only other issue is that some sections have more than one title...for example main section heading, then the cell below has a sub section then the cell below has a lower sub section, it would be this value that needs to be copied.

is this too long winded?!!

Sub must_copy_wbs()

Range("b8").Select
ActiveCell.Copy

ActiveCell.Offset(1, 0).Select

Do Until ActiveCell.Value <> ""

If ActiveCell.Offset(0, 1).Value <> "" Then ActiveCell.PasteSpecial

ActiveCell.Offset(1, 0).Select

Loop

End Sub
 
Upvote 0
i'm getting what i want but it seems i have to keep copying the loop code over and over...what am i doing wrong?

Sub must_copy_wbs()

Range("b8").Select
ActiveCell.Copy

ActiveCell.Offset(1, 0).Select

Do Until ActiveCell.Value <> ""

If ActiveCell.Offset(0, 1).Value <> "" Then ActiveCell.PasteSpecial

ActiveCell.Offset(1, 0).Select

Loop


ActiveCell.Copy

ActiveCell.Offset(1, 0).Select

Do Until ActiveCell.Value <> ""

If ActiveCell.Offset(0, 1).Value <> "" Then ActiveCell.PasteSpecial

ActiveCell.Offset(1, 0).Select

Loop



ActiveCell.Copy

ActiveCell.Offset(1, 0).Select

Do Until ActiveCell.Value <> ""

If ActiveCell.Offset(0, 1).Value <> "" Then ActiveCell.PasteSpecial

ActiveCell.Offset(1, 0).Select

Loop


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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