ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Repeat entries in rows 5 & 6 into next blank column (https://www.excelbanter.com/excel-programming/398583-repeat-entries-rows-5-6-into-next-blank-column.html)

manfareed

Repeat entries in rows 5 & 6 into next blank column
 
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



JLGWhiz

Repeat entries in rows 5 & 6 into next blank column
 
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.

"manfareed" wrote:

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



JRForm

Repeat entries in rows 5 & 6 into next blank column
 
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

"manfareed" wrote:

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



JRForm

Repeat entries in rows 5 & 6 into next blank column
 
JLGWhiz,

This is a lot easier than my suggestion!


"JLGWhiz" wrote:

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.

"manfareed" wrote:

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



manfareed

Repeat entries in rows 5 & 6 into next blank column
 
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,



"manfareed" wrote:

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



JRForm

Repeat entries in rows 5 & 6 into next blank column
 
manfareed,

So is there a headings in column k and others?

"manfareed" wrote:

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,



"manfareed" wrote:

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



manfareed

Repeat entries in rows 5 & 6 into next blank column
 
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

"JRForm" wrote:

manfareed,

So is there a headings in column k and others?

"manfareed" wrote:

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,



"manfareed" wrote:

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



manfareed

Repeat entries in rows 5 & 6 into next blank column
 
Hi,

This is now ok ...

Thanks,

Manir

"manfareed" wrote:

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




All times are GMT +1. The time now is 04:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com