View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default 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