# [Solved] Forcing a calculation

#### BrianDP1977

##### Board Regular
Anyone know of a way to use code to populate a range of cells (A1:C3) with an equation that references the same number of cells (A10:C12), then deletes the equations while maintaining the values in each cell produced by the equations before they were deleted.

The equation (“=source cell”) needs to be a consecutive reference (like when you drag it). For example, the equations for A1:D3 before they get deleted from the cells would be =A10, =B10, =C10, =A11, =B11, =C11, etc for cells A1, B1, C1, A2, B2, C2, etc respectively. I need the cells to actually calculate the value through the populated equations before they get deleted. It can’t just be a copy and paste thing.

My idea was to create some kind of loop that goes to each cell, inserts the equation, stores the resulting value in a variable, deletes the contents from the cell (i.e. the equation), then places the stored value from the variable into the cell. However, I don’t know how to code this or even if my logic is correct.

The event that will trigger this code (if I can fid something that works) is going to be a button click.

Thanks for the help.

### Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use \$ signs: \$V\$2:\$Z\$99 will always point to V2:Z99, even after copying
Those equations would just be duplicating the values from A10:C12 into A1:C3, why can't it be a copy and paste thing?

Okay, disregard. I got one problem figured out so now it can be a cut and paste. I think I have this figured out. Here’s what I’m going to use:

Code:
``````Sub Refresh()
Range("D55:S58").Select
Selection.Copy

Range("D5:S8").Select
IconFileName:=False
End Sub``````

Thanks for the help.

You don't need to select ranges in order to work with them, that could be shortened to this:

Code:
``````Sub Refresh()
Range("D55:S58").Copy
Range("D5:S8").PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub``````

Thank you very much. The way I've been trying to figure out the code is to open VBA, record a macro, note the code that appears as I do stuff, then cut and paste what I need for certain apps. It's probably time for me to go buy a book or something. However, thanks to people like yourself, this website is actually more valuable I think.

Replies
0
Views
222
Replies
7
Views
333
Replies
7
Views
148
Replies
3
Views
138
Replies
2
Views
71

1,203,513
Messages
6,055,831
Members
444,828
Latest member
StaffordStag

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