# How can I retain data from a formula?

##### New Member
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

If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

#### VoG

##### Legend
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``````

##### New Member
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!

#### VoG

##### Legend
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``````

##### New Member

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!

#### VoG

##### Legend
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``````

##### New Member

Brilliant!!

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

#### VoG

##### Legend
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``````

##### New Member
Perfect!!

Thank you for your help and very speedy responses!!

##### New Member
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!

Replies
6
Views
139
Replies
2
Views
633
Replies
19
Views
328
Replies
15
Views
217
Replies
0
Views
275

1,127,151
Messages
5,623,048
Members
415,948
Latest member
swart430

### 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.

### Which adblocker are you using?

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

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