Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Inserting Rows during a SheetChange event


I need to manipulate an excel spreadsheet so that whenever the user
types in something in cell A9, cells B9 and C9 are populated with
predefined data. A new blank row 9 then needs to be inserted, ready
for the next piece of data.

I am using the following code in the SheetChange event:

If (Target.Column = 1) And (Target.Row = 9) Then
Cells.Item(9, 2) = "A N Other" 'insert name
Cells.Item(9, 3) = "PostNo" 'insert Post
Range("A9").Select
Selection.EntireRow.Insert
End If


The name and post get inserted but the blank line does not get
inserted. Is this because I am changing the sheet during a
ChangeSheet event?

How can I get around this?

Nirmal

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Inserting Rows during a SheetChange event

Hi Nirmal,
Something like this should work, you will have to change the text to equal
what you are exactly looking for:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A9").Value = "A N Other" And Range("B9").Value = "2nd Other" And _
Range("C9").Value = "Other Data" Then
Selection.EntireRow.Insert
End If
End Sub

"Nirmal Singh" wrote:


I need to manipulate an excel spreadsheet so that whenever the user
types in something in cell A9, cells B9 and C9 are populated with
predefined data. A new blank row 9 then needs to be inserted, ready
for the next piece of data.

I am using the following code in the SheetChange event:

If (Target.Column = 1) And (Target.Row = 9) Then
Cells.Item(9, 2) = "A N Other" 'insert name
Cells.Item(9, 3) = "PostNo" 'insert Post
Range("A9").Select
Selection.EntireRow.Insert
End If


The name and post get inserted but the blank line does not get
inserted. Is this because I am changing the sheet during a
ChangeSheet event?

How can I get around this?

Nirmal


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Inserting Rows during a SheetChange event

On Thu, 6 Jan 2005 13:12:50 -0600, "Don Guillett"
wrote:

try this
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.row < 9 Or Target.Column < 1 Then Exit Sub
With Target
.Offset(0, 1) = "a"
.Offset(0, 2) = "b"
.EntireRow.Insert
End With
End Sub


Thanks Don, that is exactly what I needed.

Nirmal

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
how to handle 'sheetchange' event on 'add-in' Takoyaki Excel Programming 2 December 19th 04 04:50 AM
SheetChange Event Tom Ogilvy Excel Programming 0 November 23rd 04 07:10 PM
SheetChange Event crispbd[_34_] Excel Programming 0 November 23rd 04 06:43 PM
sheetChange event and list validation Nick Excel Programming 1 October 20th 04 10:34 PM
SheetChange event starts before .calculate finished Dave Peterson[_3_] Excel Programming 2 September 9th 03 08:49 AM


All times are GMT +1. The time now is 02:35 PM.

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

About Us

"It's about Microsoft Excel"