add some text in a cell that has just been inserted
When you use these lines of code in a for loop
Set rng = .Cells(iRow, ServiceGroupColumn) rng.Offset(SvcGrpNum / 2, 0).Resize(rowsToAdd + 1).EntireRow What would be the way to add some text in the irow cell for all those inserted rows. tia, |
add some text in a cell that has just been inserted
I'm not sure what you mean by the irow cell.
You sure you didn't mean that you want to populate servicegroupcolumn in each of the inserted rows? If yes, this worked ok for me: Option Explicit Sub testme() Dim Rng As Range Dim iRow As Long Dim ServiceGroupColumn As Long Dim SvcGrpNum As Long Dim RowsToAdd As Long ServiceGroupColumn = 3 iRow = 4 SvcGrpNum = 4 RowsToAdd = 17 With Worksheets("Sheet1") Set Rng = .Cells(iRow, ServiceGroupColumn) End With Rng.Offset(SvcGrpNum / 2, 0).Resize(RowsToAdd + 1).EntireRow.Insert Rng.Offset(SvcGrpNum / 2, 0).Resize(RowsToAdd + 1).Value = "hi there" End Sub Janis wrote: When you use these lines of code in a for loop Set rng = .Cells(iRow, ServiceGroupColumn) rng.Offset(SvcGrpNum / 2, 0).Resize(rowsToAdd + 1).EntireRow What would be the way to add some text in the irow cell for all those inserted rows. tia, -- Dave Peterson |
add some text in a cell that has just been inserted
thanks for answering :-) it helped, I was doing it in a much harder way. "Dave Peterson" wrote: I'm not sure what you mean by the irow cell. You sure you didn't mean that you want to populate servicegroupcolumn in each of the inserted rows? If yes, this worked ok for me: Option Explicit Sub testme() Dim Rng As Range Dim iRow As Long Dim ServiceGroupColumn As Long Dim SvcGrpNum As Long Dim RowsToAdd As Long ServiceGroupColumn = 3 iRow = 4 SvcGrpNum = 4 RowsToAdd = 17 With Worksheets("Sheet1") Set Rng = .Cells(iRow, ServiceGroupColumn) End With Rng.Offset(SvcGrpNum / 2, 0).Resize(RowsToAdd + 1).EntireRow.Insert Rng.Offset(SvcGrpNum / 2, 0).Resize(RowsToAdd + 1).Value = "hi there" End Sub Janis wrote: When you use these lines of code in a for loop Set rng = .Cells(iRow, ServiceGroupColumn) rng.Offset(SvcGrpNum / 2, 0).Resize(rowsToAdd + 1).EntireRow What would be the way to add some text in the irow cell for all those inserted rows. tia, -- Dave Peterson |
All times are GMT +1. The time now is 12:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com