how to create a time cell

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
looking for a time cell...
just an example to understand what i want to achieve here.
suppose i have 5 Cells.. A3 B3 C3 D3 and E3

It all starts from a single Cell .. F3

so if F3 = ChangeValue
then E3 = old value of F3 before Change
and D3 = old value of E3 before change
and C3 = old value of D3 before change
and B3 = old value of C3 before change
finally A3 = old value of B3 before change

Its a chain reaction...

A picture demonstration where each time 100 is Added in cell F3...
time.jpg



help will be appreciated..
Thank You
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You have done the hard bit. Just replace your "pseudocode" with "real" code.

The only difference being that you put it in reverse order so this bit is LAST
Code:
'- pseudocode
F3 = ChangeValue
 
Last edited:
Upvote 0
You have done the hard bit. Just replace your "pseudocode" with "real" code.

The only difference being that you put it in reverse order so this bit is LAST
Code:
'- pseudocode
F3 = ChangeValue

Hey Brian Thanks for the Post.. im kindof still new to learning Excel Vba and stuff... could you kindly tell how to put this code in worksheet? also is there a formula for all this?
 
Upvote 0
You can only do this with code because one you overwrite a cell value it is lost.

Code:
'=============================================================================
'- CHANGE CELL VALUES WHEN CELL F3 IS DOUBLE CLICKED
'- This code goes into sheet code module
'- Right click tab. View Code.
'=============================================================================
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim C As Integer    ' column
    Dim NewValue As Variant
    '-------------------------------------------------------------------------
    If Target.Address = "$F$3" Then
        '- InputBox for new cell value
        NewValue = InputBox("New Value for cell", " NEW VALUE")
        If NewValue = "" Then Exit Sub
        '----------------------------------------------------------------------
        '- Change cell values columns A to E to value in next cell'
        For C = 1 To 5
            Cells(3, C).Value = Cells(3, C + 1).Value
        Next
        '----------------------------------------------------------------------
        '- PUT NEW VALUE IN F3
        Range("F3").Value = NewValue
        Beep
        '----------------------------------------------------------------------
    End If
End Sub
'------------------------------------------------------------------------------
 
Upvote 0
Hi Brian...
just to seal the deal could you please alter code for not a double click event but for when value is changed even without touching the cell F3...
reason for me to want this is I can achieve a history of my past values that i feed in cell and i always feel like if i had enter the correct value and by doing this code i could easily review my values in real time.

Many thanks for your effort :)...
 
Upvote 0
Could anyone make a suggestion please??
Help will be appreciated.:)
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,686
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top