Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am working with the following code that is working fine, I just need some help to make an adjustment to it as I can't figure it out. At the time of 'Names copied down to the inserted rows' I would like it to copy the values from the range iRow "A" to iRow "W" to the inserted row instead of just iRow "A" as it is now. Thanks for your help. Sub InsertRowsBasedOnCount() Dim wks As Worksheet Dim iRow As Long Dim HowManyRows As Variant Dim FirstRow As Long Dim LastRow As Long Set wks = Worksheets("Data resolution category") With wks FirstRow = 1 LastRow = .Cells(.Rows.Count, "X").End(xlUp).Row For iRow = LastRow To FirstRow Step -1 HowManyRows = .Cells(iRow, "X").Value If IsNumeric(HowManyRows) Then 'some minor testing If HowManyRows 1 _ And HowManyRows < 100 Then .Rows(iRow + 1).Resize(HowManyRows - 1).Insert 'Names copied down to the inserted rows .Cells(iRow + 1, "A").Resize(HowManyRows - 1).Value _ = .Cells(iRow, "A").Value End If End If Next iRow End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need Macro- Insert rows based on dates and copy info from that row | Excel Discussion (Misc queries) | |||
Insert rows and keep merged cells in the inserted row | Excel Discussion (Misc queries) | |||
copy rows based on conditions and insert them into another sheet... | Excel Programming | |||
Set new range based on rng.Offset(rng.Rows.Count, 0).Resize(1, 1) | Excel Programming | |||
automatically insert formula when new rows are inserted | Excel Worksheet Functions |