ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change a formula (https://www.excelbanter.com/excel-programming/338146-change-formula.html)

jobra

change a formula
 
Hi, is there a programming way to change this:
Cell A10=A2+B2
into this
Cell A10=$a$2+B2
Thanks in advance

Bob Phillips[_6_]

change a formula
 
select the cell
hit F2
highlight the A2 part
F4 - each F4 toggles through the absolute/relative combinations

--
HTH

Bob Phillips

"jobra" wrote in message
...
Hi, is there a programming way to change this:
Cell A10=A2+B2
into this
Cell A10=$a$2+B2
Thanks in advance




Tom Ogilvy

change a formula
 
The built in function
sForm = "=A2+B2"
? application.ConvertFormula(sForm,xlA1,xlA1,xlAbsol ute)
=$A$2+$B$2

will not work on just one argument, so you would have to develop custom code
to do the conversion.

You can get the directprecedents

? Range("A10").DirectPrecedents.Address
$A$2:$B$2


but this doesn't seem real useful in this case.

? replace(sForm,"A2","$A$2")
=$A$2+B2

is a very specific solution. You would have to state your real need and
what the conditions are.

--
Regards,
Tom Ogilvy

"jobra" wrote in message
...
Hi, is there a programming way to change this:
Cell A10=A2+B2
into this
Cell A10=$a$2+B2
Thanks in advance




jobra

change a formula
 


"Bob Phillips" wrote:

select the cell
hit F2
highlight the A2 part
F4 - each F4 toggles through the absolute/relative combinations

-- Thanks Bob, but do you know a way to program this into a macro?


HTH

Bob Phillips

"jobra" wrote in message
...
Hi, is there a programming way to change this:
Cell A10=A2+B2
into this
Cell A10=$a$2+B2
Thanks in advance






All times are GMT +1. The time now is 02:21 AM.

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