ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with dulicate range and highlight rows (https://www.excelbanter.com/excel-programming/416431-help-dulicate-range-highlight-rows.html)

ryanp

Help with dulicate range and highlight rows
 
Hi,

My table has data from coluum A to W. I would like to duplicate the data in
coluum A to H. Each new row will be right below the original one. Then the
new rows will be hightlighted from coluum A to W.

I appreciate your help.



Dave Peterson

Help with dulicate range and highlight rows
 
Maybe this'll get you started:

Option Explicit
Sub testme01()

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

With wks
FirstRow = 2 'headers in row 1?
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
.Rows(iRow + 1).Insert
.Cells(iRow, "A").Range("a1:h1").Copy _
Destination:=.Cells(iRow + 1, "A")
.Cells(iRow + 1, "A").Range("a1:w1").Interior.ColorIndex = 3
Next iRow
End With

End Sub



ryanp wrote:

Hi,

My table has data from coluum A to W. I would like to duplicate the data in
coluum A to H. Each new row will be right below the original one. Then the
new rows will be hightlighted from coluum A to W.

I appreciate your help.


--

Dave Peterson


All times are GMT +1. The time now is 03:55 AM.

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