PC Review


Reply
Thread Tools Rate Thread

Can anyone point me in the right direction please?

 
 
jonathan@pink-equine.com
Guest
Posts: n/a
 
      25th Jan 2007
my code writes a changing calculation value to another part of my
spreadsheet.
I am trying to amend my code to paste to another worksheet in the
workbook and also write to a different line each time the value changes


can anyone point me in the right direction

current code below



Private Sub Worksheet_Calculate()
Worksheet_Change Range("$A$2")
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Application.ScreenUpdating = False
With Sheets("sheet1")
..Range("A22").Copy
..Range("F2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End With
Application.ScreenUpdating = False

End If

End Sub

thanks Jonathan

 
Reply With Quote
 
 
 
 
merjet
Guest
Posts: n/a
 
      25th Jan 2007
Here is a modified Sub, with changes marked by "new".

Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRow As Long 'new
If Target.Address = "$A$2" Then
Application.ScreenUpdating = False
With Sheets("sheet1")
.Range("A22").Copy
.Range("F2").PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
iRow = Sheets("Sheet2").Range("A65536").End(xlUp).Row 'new
Sheets("Sheet2").Range("A" & iRow + 1).PasteSpecial
Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'new
Application.ScreenUpdating = False
Application.CutCopyMode = False 'new
End If
End Sub

By the way, I saw no need for the special Worksheet_Calculate()

Hth,
Merjet

 
Reply With Quote
 
jonathan@pink-equine.com
Guest
Posts: n/a
 
      25th Jan 2007


Hi Merjet

Thanks i really appreciate your help

I understood that because the cell that changes is as result of a
formula and a dde link, worksheet_change won't recognise the
information and i have to use worksheet calculate. Can you clarify
this for me

regards


Jonathan

 
Reply With Quote
 
merjet
Guest
Posts: n/a
 
      25th Jan 2007
You're right. Your special Worksheet_Calculate is needed if A2 has a
formula and its value changes as a result of another cell changing.
Worksheet_Change fires only
when its Target is changed manually, and earlier I assumed changing A2
manually.

Hth,
Merjet

 
Reply With Quote
 
jonathan@pink-equine.com
Guest
Posts: n/a
 
      25th Jan 2007
Merjet
Thanks for your assistance its works great!!

One very happy person!!

Jonathan

 
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
A point in the right direction... Jaybird Microsoft Excel Programming 0 2nd May 2008 03:28 PM
Point me in the right direction =?Utf-8?B?Q2hlcmk=?= Microsoft Outlook Discussion 1 19th May 2007 04:49 PM
Point me in the right direction?? Robert M. Cepek Microsoft Windows 2000 DNS 2 3rd Mar 2004 08:16 AM
Can someone help/point me in the right direction? Stu Padasso Windows XP Video 1 22nd Jan 2004 10:31 PM
Can someone point me in the right direction? Mike G. Microsoft Outlook Interoperability 1 10th Jul 2003 09:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:25 PM.