Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Worksheet_Change Event

Hi
I have a link in A1 in sheet 1, pasted from A1 in sheet 2.
I need to record the data in column B, where when A1 value changes the new
value is then put in a new row in column B. The following code works only
when I Double click A1, then click on any other cell. It does not
automatically update column B as I would expect. I have sheet calculation set
to automatic and pressing F9 has no effect. Any ideas, I'm desperate to get
this working, I know it works because I had it working a few years ago, but I
cannot find the code.
Thanks in Advance
Alec

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, LR As Long
If Target.Address = "$A$1" Then
LR = Cells(Rows.Count, "B").End(xlUp).Row
If Not (LR = 1 And Len(Cells(LR, "B").Value) = 0) Then LR = LR + 1
Application.EnableEvents = False
Cells(LR, "B").Value = Range("A1").Value
Application.EnableEvents = True
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Worksheet_Change Event

this continues from an earlier thread doesn't it?

anyway, set another cell as =1*A1
that means it will calculate when A1's value changes.
Instead of using the CHANGE event, use the CALCULATE event:

Private Sub Worksheet_Calculate()
' your code here
End Sub
"Alectrical" wrote:

Hi
I have a link in A1 in sheet 1, pasted from A1 in sheet 2.
I need to record the data in column B, where when A1 value changes the new
value is then put in a new row in column B. The following code works only
when I Double click A1, then click on any other cell. It does not
automatically update column B as I would expect. I have sheet calculation set
to automatic and pressing F9 has no effect. Any ideas, I'm desperate to get
this working, I know it works because I had it working a few years ago, but I
cannot find the code.
Thanks in Advance
Alec

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, LR As Long
If Target.Address = "$A$1" Then
LR = Cells(Rows.Count, "B").End(xlUp).Row
If Not (LR = 1 And Len(Cells(LR, "B").Value) = 0) Then LR = LR + 1
Application.EnableEvents = False
Cells(LR, "B").Value = Range("A1").Value
Application.EnableEvents = True
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Worksheet_Change Event

Thanks for your reply Patrick.
I've tried the Calculate event but get the error message - Variable not
Defined with Target highlighted. Also tried changing Private Sub
Worksheet_Calculate() to Private Sub Worksheet_Calculate(ByVal Target As
Range) but get the error message "procedure declaration does not match
description of event or procedure having the same name"

"Patrick Molloy" wrote:

this continues from an earlier thread doesn't it?

anyway, set another cell as =1*A1
that means it will calculate when A1's value changes.
Instead of using the CHANGE event, use the CALCULATE event:

Private Sub Worksheet_Calculate()
' your code here
End Sub
"Alectrical" wrote:

Hi
I have a link in A1 in sheet 1, pasted from A1 in sheet 2.
I need to record the data in column B, where when A1 value changes the new
value is then put in a new row in column B. The following code works only
when I Double click A1, then click on any other cell. It does not
automatically update column B as I would expect. I have sheet calculation set
to automatic and pressing F9 has no effect. Any ideas, I'm desperate to get
this working, I know it works because I had it working a few years ago, but I
cannot find the code.
Thanks in Advance
Alec

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, LR As Long
If Target.Address = "$A$1" Then
LR = Cells(Rows.Count, "B").End(xlUp).Row
If Not (LR = 1 And Len(Cells(LR, "B").Value) = 0) Then LR = LR + 1
Application.EnableEvents = False
Cells(LR, "B").Value = Range("A1").Value
Application.EnableEvents = True
End If
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Worksheet_Change Event

Thanks for your reply Don
Tried that code and nothing is happening, it appears the Worksheet_Change
Event is not working as it should, All I have done is selected the tab at the
bottom of the sheet, and selected view code and pasted. Do I have to declare
the event anywhere else.

"Don Guillett" wrote:

This simple macro will take ANY entry, when entered, in col A and copy to
the next available row in col B

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 2 Or Target.Column < 1 Then Exit Sub
Cells(Rows.Count, 2).End(xlUp).Offset(1) = Target
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Alectrical" wrote in message
...
Hi
I have a link in A1 in sheet 1, pasted from A1 in sheet 2.
I need to record the data in column B, where when A1 value changes the new
value is then put in a new row in column B. The following code works only
when I Double click A1, then click on any other cell. It does not
automatically update column B as I would expect. I have sheet calculation
set
to automatic and pressing F9 has no effect. Any ideas, I'm desperate to
get
this working, I know it works because I had it working a few years ago,
but I
cannot find the code.
Thanks in Advance
Alec

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, LR As Long
If Target.Address = "$A$1" Then
LR = Cells(Rows.Count, "B").End(xlUp).Row
If Not (LR = 1 And Len(Cells(LR, "B").Value) = 0) Then LR = LR + 1
Application.EnableEvents = False
Cells(LR, "B").Value = Range("A1").Value
Application.EnableEvents = True
End If
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Worksheet_Change Event

Maybe you inadvertently caused events to be false. Run this from anywhere
sub fixit()
application.enableevents=true
end sub

The worksheet_change macro depends on you entering something in a cell in
col A below row 1
If desired, send your file to my address below along with this msg and
a clear explanation of what you want and before/after examples.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Alectrical" wrote in message
...
Thanks for your reply Don
Tried that code and nothing is happening, it appears the Worksheet_Change
Event is not working as it should, All I have done is selected the tab at
the
bottom of the sheet, and selected view code and pasted. Do I have to
declare
the event anywhere else.

"Don Guillett" wrote:

This simple macro will take ANY entry, when entered, in col A and copy
to
the next available row in col B

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 2 Or Target.Column < 1 Then Exit Sub
Cells(Rows.Count, 2).End(xlUp).Offset(1) = Target
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Alectrical" wrote in message
...
Hi
I have a link in A1 in sheet 1, pasted from A1 in sheet 2.
I need to record the data in column B, where when A1 value changes the
new
value is then put in a new row in column B. The following code works
only
when I Double click A1, then click on any other cell. It does not
automatically update column B as I would expect. I have sheet
calculation
set
to automatic and pressing F9 has no effect. Any ideas, I'm desperate to
get
this working, I know it works because I had it working a few years ago,
but I
cannot find the code.
Thanks in Advance
Alec

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, LR As Long
If Target.Address = "$A$1" Then
LR = Cells(Rows.Count, "B").End(xlUp).Row
If Not (LR = 1 And Len(Cells(LR, "B").Value) = 0) Then LR = LR + 1
Application.EnableEvents = False
Cells(LR, "B").Value = Range("A1").Value
Application.EnableEvents = True
End If
End Sub




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 event Joanne Excel Programming 8 January 10th 08 08:42 AM
Worksheet_Change Event thewizz Excel Programming 4 November 2nd 07 02:15 PM
How do I change a Worksheet_change event to a beforesave event? Tueanker Excel Programming 5 June 29th 07 03:00 PM
Worksheet_change event. Mike K Excel Programming 8 October 24th 04 09:00 PM
Worksheet_Change Event cmcfalls[_4_] Excel Programming 3 April 12th 04 09:47 PM


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