Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Getting Worksheet_Change to Ignore First Row


I am using the following code to add formulas to the next row when
data is entered in column A. The formulas are in columns B, C, D, and
E.

Row 8 is a header row.
Data entry starts in cell A9.

It works except for data entered in A9. When data is entered in A9
the header row is copied to B9:E9.

How can I get this code to ignore data entry into cell A9?


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim c As Range, i As Long
On Error Resume Next
Set c = Intersect(Target, Columns(1))
If c Is Nothing Then Exit Sub
If IsEmpty(c.Offset(-1, 0)) Or Not IsEmpty(c.Offset(1, 0)) Then
Exit Sub
i = c.Row
Application.EnableEvents = False
Range("B" & i - 1 & ":E" & i - 1).Copy Range("B" & i & ":E" & i)
Application.EnableEvents = True
On Error GoTo 0
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 185
Default Getting Worksheet_Change to Ignore First Row

Brad

Start your code with

If Not Application.Intersect(Range("A9"),Target) is Nothing Then
Exit Sub
End If


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
web:
www.excelusergroup.org
web: www.nickhodge.co.uk





"General Specific" wrote in message
...

I am using the following code to add formulas to the next row when
data is entered in column A. The formulas are in columns B, C, D, and
E.

Row 8 is a header row.
Data entry starts in cell A9.

It works except for data entered in A9. When data is entered in A9
the header row is copied to B9:E9.

How can I get this code to ignore data entry into cell A9?


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim c As Range, i As Long
On Error Resume Next
Set c = Intersect(Target, Columns(1))
If c Is Nothing Then Exit Sub
If IsEmpty(c.Offset(-1, 0)) Or Not IsEmpty(c.Offset(1, 0)) Then
Exit Sub
i = c.Row
Application.EnableEvents = False
Range("B" & i - 1 & ":E" & i - 1).Copy Range("B" & i & ":E" & i)
Application.EnableEvents = True
On Error GoTo 0
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Getting Worksheet_Change to Ignore First Row

On May 20, 4:41*pm, "Nick Hodge" wrote:
Brad

Start your code with

If Not Application.Intersect(Range("A9"),Target) is Nothing Then
Exit Sub
End If

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England

web:www.excelusergroup.org
web:www.nickhodge.co.uk

"General Specific" wrote in message

...





I am using the following code to add formulas to the next row when
data is entered in column A. *The formulas are in columns B, C, D, and
E.


Row 8 is a header row.
Data entry starts in cell A9.


It works except for data entered in A9. *When data is entered in A9
the header row is copied to B9:E9.


How can I get this code to ignore data entry into cell A9?


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
* *Dim c As Range, i As Long
* *On Error Resume Next
* *Set c = Intersect(Target, Columns(1))
* *If c Is Nothing Then Exit Sub
* *If IsEmpty(c.Offset(-1, 0)) Or Not IsEmpty(c.Offset(1, 0)) Then
Exit Sub
* *i = c.Row
* *Application.EnableEvents = False
* *Range("B" & i - 1 & ":E" & i - 1).Copy Range("B" & i & ":E" & i)
* *Application.EnableEvents = True
* *On Error GoTo 0
End Sub- Hide quoted text -


- Show quoted text -


Excellent!

Now, this doesn't work if data is pasted, like if 20 numbers are
pasted at once. Why?
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
Worksheet_Change Little Penny Excel Programming 6 December 1st 06 06:29 PM
Worksheet_Change DDE Johan de Kok Excel Programming 2 April 23rd 05 06:32 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 09:13 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"