VBA - Remove formula based on date

DancingIsForbidden

New Member
Joined
Sep 10, 2014
Messages
8
Hi there - Former lurker. First time poster.

I'm looking for some help with a table I'm creating. This table gathers the amount of data we input into our spreadsheet but we wish to arrange it in order to display the amount of data we input on a daily basis.

e.g.
10/09/2014: 234
11/09/2014: 303

What we currently have is the value we began off with in the morning and the value we've ended up with at night.

We would like the night value to convert to a value so that we may calculate the new data gathered on the new day.

All based on the date of course. Is this possible?

Many thanks
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

NeonRedSharpie

Well-known Member
Joined
Jul 14, 2014
Messages
1,678
I would put in a worksheet_calculate event and then check it against the computer clock. So, if the time is after, say, 11:59PM and the sheet is calculated, then store that cell as a value.
 

PGuru

Board Regular
Joined
Sep 16, 2006
Messages
55
Have a macro that checks the system date against a cell that holds the "last updated" date every time the workbook is opened. If one > the other, add a new line to your table and update the "last updated" cell.

..assuming I've understood you correctly
 

DancingIsForbidden

New Member
Joined
Sep 10, 2014
Messages
8
Many thanks guys. I'm going to attach a picture with exactly what I'm doing to paint a better picture.

4iAdaVU.png
 

PGuru

Board Regular
Joined
Sep 16, 2006
Messages
55

ADVERTISEMENT

I see a red x, so a description may help...!
 

NeonRedSharpie

Well-known Member
Joined
Jul 14, 2014
Messages
1,678

ADVERTISEMENT

I see a red x, so a description may help...!


We need a change event (calc, on open, on close) to execute cells(x, 4).value=cells(x, 4).Value where x is determined IF A is BEFORE current clock time.
 

NeonRedSharpie

Well-known Member
Joined
Jul 14, 2014
Messages
1,678
That was my description to PGuru.

Code:
Private Sub Workbook_Open()
    For x = 2 To [COLOR=#333333]Cells(Rows.Count, "A").End(xlUp).Row[/COLOR]
        If Cells(x, 1) < Now Then
            Cells(x, 4).Value = Cells(x, 4)
        End If
    Next x
End Sub

I think this code should be all you need. Obviously test it before saving, but if you throw that into your worksheet code, that should work for you.
 

DancingIsForbidden

New Member
Joined
Sep 10, 2014
Messages
8
That was my description to PGuru.

Code:
Private Sub Workbook_Open()
    For x = 2 To [COLOR=#333333]Cells(Rows.Count, "A").End(xlUp).Row[/COLOR]
        If Cells(x, 1) < Now Then
            Cells(x, 4).Value = Cells(x, 4)
        End If
    Next x
End Sub

I think this code should be all you need. Obviously test it before saving, but if you throw that into your worksheet code, that should work for you.


I'm not entirely sure if I understand this. Is it possible to implement this in Google Sheets?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,822
Messages
5,598,307
Members
414,224
Latest member
Crazy_FC

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
Top