Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Write data inthe worksheet / array


Situation:

Cells 14,B holds my variable. This changes over time (by the vb code).

Is there some way that, when the data changes it will be written in a
new cell.

Something like this.

If Range("B14") < Range("B14") Then
old new

copy it into cell C1. then C2, then C3 etc etc

And then loop this until no more changes.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Write data inthe worksheet / array


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B14"
Dim iRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
iRow = Me.Cells(Me.Rows.Count, "C").End(xlUp).Row
If iRow 1 Or Me.Cells(iRow, "C").Value < "" Then
iRow = iRow + 1
End If
Me.Cells(iRow, "C").Value = .Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Robert" wrote in message
oups.com...

Situation:

Cells 14,B holds my variable. This changes over time (by the vb code).

Is there some way that, when the data changes it will be written in a
new cell.

Something like this.

If Range("B14") < Range("B14") Then
old new

copy it into cell C1. then C2, then C3 etc etc

And then loop this until no more changes.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Write data inthe worksheet / array

It looks like you want to trace the values that get put into B14. try this
code. the worksheet change function need to be placed in the Sheet code, not
a module.

Sub worksheet_change(ByVal target As Range)

If (target.Row = 14) And _
(target.Column = 2) Then

'get last value in column c
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
oldvalue = Cells(LastRow, "C")

If (LastRow = 1) And IsEmpty(oldvalue) Then
Cells(1, "C") = target
Else
If target < oldvalue Then

Cells(LastRow + 1, "C") = target
End If
End If
End If

End Sub


"Robert" wrote:


Situation:

Cells 14,B holds my variable. This changes over time (by the vb code).

Is there some way that, when the data changes it will be written in a
new cell.

Something like this.

If Range("B14") < Range("B14") Then
old new

copy it into cell C1. then C2, then C3 etc etc

And then loop this until no more changes.


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
select data and write results to new worksheet in same workbook CCJ Excel Discussion (Misc queries) 2 March 26th 09 10:32 PM
Array write Bharath Rajamani Excel Programming 4 May 8th 07 11:24 PM
Transfer data from worksheet to array Pradip Jain Excel Programming 6 October 24th 06 09:03 PM
Array to read data from one sheet and write to another if it meets criteria RudyShoe Excel Programming 2 August 2nd 06 04:38 PM
Formula to fill inthe Quarter gls858 New Users to Excel 7 June 16th 05 05:53 PM


All times are GMT +1. The time now is 10:21 AM.

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"