Repeat entries in rows 5 & 6 into next blank column

G

Guest

Hi,

I have headings in rows 5&6 which I would like repeated in the next blank
column or columns to the right. Each heading needs to be repeated until nth
column which has data.

The macro should start looking for data to repeat from column "E" onwards
and autofill say column "F" rows 5 & 6 if blank.

Thank
 
G

Guest

I am not sure you want AutoFill. Try this first:

Sub ExpndHdng()
lstc = ActiveSheet.Cells(7, Columns.Count).End(xlToLeft).Column
Range("$E$5:$E$6").Copy Range(Cells(5, 5), Cells(6, lstc))
End Sub

If this does not do what you want, then post back with more detail.
 
G

Guest

manfareed,
I think this is what your asking for.

Sub Manfreed()

Dim LastCell As String

'look for the last data value
Range("e7").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 0).Select
LastCell = ActiveCell.Offset(-1, 0).Address
LastCell = Replace(LastCell, "$", "")
LastCell = "E5:" & LastCell & ""

'Copy and paste it
Range("E5:E6").Select
Selection.Copy
Range(LastCell).Select
ActiveSheet.Paste
Application.CutCopyMode = False

'Return to E5
Range("E5").Select
End Sub
 
G

Guest

Hi,

The first heading needs only to be repeated until the next column is reached
with data. For example from column E as the start point. If "E" has data and
then next column with data is "K" . The data from "E" should only populate up
to column "I" and so on. After column "K" blank rows 5&6 should be populated
by data in column "K".

Thanks,
 
G

Guest

Hi,

Yes there are headings in other columns but in between there will be blank
columns.
Each time I run a report with different data the columns with headings also
change.

Thanks,

Manir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top