ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   changing lists of cells to absolute values using a macro (https://www.excelbanter.com/excel-discussion-misc-queries/226144-changing-lists-cells-absolute-values-using-macro.html)

Allerum30

changing lists of cells to absolute values using a macro
 
I need to change several lists of cells from normal(ie. cell A1 shows the
value in cell C4) I need to change that value to $C$4. I do it by clicking
the cell and hitting F2 then F4. For a list of 20 cells. When I try to use a
macro to perform this function(using relative reference or not)all it does is
give me a list of 20 $C$4's. what am I doing wrong?

Luke M

changing lists of cells to absolute values using a macro
 
Your macro probably says something like
cellFormulaR1C1 = R4C3

Which, of course, will always generate C4.

Instead of that, use this short macro to do what you want.

Sub AbsoluteReference()
'Modify range size in next line accordingly
For Each cell In Range("C4:C24")
cell.Formula = Application.ConvertFormula(cell.Formula, xlA1, xlA1,
xlAbsolute)
Next cell
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Allerum30" wrote:

I need to change several lists of cells from normal(ie. cell A1 shows the
value in cell C4) I need to change that value to $C$4. I do it by clicking
the cell and hitting F2 then F4. For a list of 20 cells. When I try to use a
macro to perform this function(using relative reference or not)all it does is
give me a list of 20 $C$4's. what am I doing wrong?



All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com