Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default 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,

  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Inserted HTML text as Hyperlink [email protected] Excel Worksheet Functions 3 December 2nd 08 10:48 PM
Can I send an inserted shape behind the cell text? stevieB Excel Discussion (Misc queries) 1 November 19th 08 06:53 PM
Get a specific cell value/text inserted in a macro ST Excel Programming 1 November 1st 06 08:11 PM
Blank space gets inserted after text Ros M New Users to Excel 2 September 26th 05 02:07 PM
Text not all displaying in a cell, what is max that can be inserted? Althea Excel Worksheet Functions 4 May 9th 05 02:41 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"