PC Review


Reply
Thread Tools Rate Thread

add some text in a cell that has just been inserted

 
 
=?Utf-8?B?SmFuaXM=?=
Guest
Posts: n/a
 
      4th Oct 2007
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,

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      4th Oct 2007
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 With Quote
 
=?Utf-8?B?SmFuaXM=?=
Guest
Posts: n/a
 
      4th Oct 2007

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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I send an inserted shape behind the cell text? stevieB Microsoft Excel Misc 1 19th Nov 2008 06:53 PM
Get a specific cell value/text inserted in a macro =?Utf-8?B?U1Q=?= Microsoft Excel Programming 1 1st Nov 2006 08:11 PM
select text in cell based on text from another cell, paste the text at the begining of a thrid cell, etc... jsd219 Microsoft Excel Programming 0 19th Oct 2006 05:04 PM
Text not all displaying in a cell, what is max that can be inserted? Althea Microsoft Excel Worksheet Functions 4 9th May 2005 02:41 AM
Spaces inserted around text inserted into replies in HTML format Dan Cooperstock Microsoft Outlook Discussion 0 9th Jun 2004 02:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:41 AM.