View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Harlan is offline
external usenet poster
 
Posts: 23
Default "Remembering" Cell Values

My sheet is actually a lot more complicated than what I originally posted,
but I just wanted to see if something like this was possible. Would you be
willing to help me out if I actually send the workbook to you to look. I
think that is the only way for me to properly explain it.

Thanks

"JLatham" wrote:

SECOND TRY - system claimed it was too busy to accept my previous reply.

You can probably do this with some VBA code attached to the first sheet's
Change event. The code below assumes that:
On sheet 1, A1 holds the name of the month and entries are made in column A
below it.
On sheet 2, cells A1:L1 hold names of the 12 months spelled exactly the same
as they are/will be in A1 on sheet 1.

I recommend setting up 'sheet 2' with the 12 month names before adding the
code below to the workbook.

Open your workbook, select the 1st sheet and right-click on it's name tab
and choose [View Code] from the popup list. Copy the code below and paste it
into the code module presented to you. Change the name of "Sheet2" to
whatever it really is in your workbook. After that it should work pretty
well for you.

Private Sub Worksheet_Change(ByVal Target As Range)
'ignores all changes except those in column A
'and ignores a change in A1
'also ignores changes that affect multiple cells
'A1 is assumed to hold a Month name spelled
'exactly like they are in row 1 of Sheet2
Dim destWS As Worksheet ' will represent Sheet2
Dim destMonths As Range ' A1:L1 on Sheet2
Dim anyMonth As Range

'did change affect multiple cells (as large delete)
If Target.Cells.Count 1 Then
Exit Sub
End If
'check if change in Column A and below row 1
If Target.Row = 1 Or Target.Column 1 Then
Exit Sub
End If
'change took place in column A below row 1
'change sheet name as required
Set destWS = ThisWorkbook.Worksheets("Sheet2")
Set destMonths = destWS.Range("A1:L1")
For Each anyMonth In destMonths
If anyMonth = Range("A1") Then ' month on this sheet
destWS.Cells(Target.Row, anyMonth.Column) = Target.Value
Exit For
End If
Next
'housekeeping
Set anyMonth = Nothing
Set destMonths = Nothing
Set destWS = Nothing
End Sub


"Harlan" wrote:

I don't really think this is possible, but I'm going to ask anyway:
Is it possible to create a function that "remembers" the value placed in it?
I want to use one column to change values as needed. I then want those
values placed in a column (A) on a different sheet (2). That sheet is
separated into columns based on months. The month is also a variable in the
first sheet (1). When I change the month, I need to put new values in column
A, but I want the values that I first entered to stay the same.
Does this make any sense? Is it possible?
Thanks in advance.