How can I retain data from a formula?

PaddyG

New Member
Joined
Nov 4, 2008
Messages
18
I need a solution so that each day I can get a value from a single cell but it appears in a new column each day.

eg, A1 contains a numerical value (based on a formula)
Each day there is a new column, say, Monday = B1, Tuesday = C1 etc.
On Monday B1 takes the value of A1 and 'freezes' the value in B1
On Tuesday C1 takes the value of A1 and 'freezes' the value in C1, but the value in B1 remains as it was when it was originally frozen.

Any help on this would be greatly appreciated!!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Something like this perhaps

Code:
Sub test()
Dim LC As Long
LC = Cells(1, Columns.Count).End(xlToLeft).Column
With Cells(1, LC)
    .Copy Destination:=.Offset(, 1)
    .Value = .Value
End With
End Sub
 
Upvote 0
Wow- nearly there with this one....it's saving the data and moving along one cell to the right each time, but it's taking the value from the previous cell on the left, whereas I need it to always take the value of A1.

It's probably something very easy to do, but I'm not very good at this....

I'd be grateful for a more of your assistance.

Thanks!
 
Upvote 0
Perhaps this

Code:
Sub test()
Dim LC As Long
LC = Cells(1, Columns.Count).End(xlToLeft).Column
With Cells(1, LC)
    Cells(1, 1).Copy Destination:=.Offset(, 1)
    .Value = .Value
End With
End Sub
 
Upvote 0
It's returning a value of '0' - I think this is because A1 is referencing another cell to get it's value (ie, A1 "=A7"). However, when I remove the formula and directly type the value into A1 it does work.

Sorry to be a pain!
 
Upvote 0
This seems to work

Code:
Sub test()
Dim LC As Long
LC = Cells(1, Columns.Count).End(xlToLeft).Column
With Cells(1, LC)
    .Offset(, 1).Formula = Cells(1, 1).Formula
    .Value = .Value
End With
End Sub
 
Upvote 0
Brilliant!!

One final question - how can i amend it so that it pulls the value from a different cell eg B6?

Thanks for all your help!
 
Upvote 0
Try

Code:
Sub test()
Dim LC As Long
LC = Cells(1, Columns.Count).End(xlToLeft).Column
With Cells(1, LC)
    .Offset(, 1).Formula = Cells(6, 2).Formula
    .Value = .Value
End With
End Sub
 
Upvote 0
Playing with this a bit more - is there any way I can put multiple instances of this in one macro, eg, run the macro and it updates many cells pulling value from many sources.

Ideally I'd like the macro to run once and update multiple cells, rather than having a macro for each cell (row)?

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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