Programmatically retrieving the cell formula expression in terms of custom cell names

DonSnow

New member
Joined
Apr 29, 2021
Messages
2
Reaction score
0
Points
0
Excel Version(s)
365
Hi,

I am writing the custom cell names and their corresponding formulas to a csv file. In the attached excel sheet, all relevant cells including the formula cells have existing and customized cell names, namely, NewPred_1A, NewPred_1B, NewPred_1C, and NewPred_1D. My goal is to retrieve the expression of the cell location D1(NewPred_1D) in terms of custom names of the other three cells, NewPred_1A, NewPred_1B and NewPred_1C. Currently, the expression for D1(or NewPred_1D) is '=A1+B1+C1' by default even if there are custom names for the cells.

What will I do such that D1 will have an expression of '=NewPred_1A + NewPred_1B + NewPred_1C' without manually updating the expression? How can we assign the formula expression of D1 to a variable? I tried this:

FormulaVar = Worksheets(ActiveSheet.Name).Cells(r, c).Formula but didn't work. It still displayed the '=A1+B1+C1' string. It should dislplay the '=NewPred_1A + NewPred_1B + NewPred_1C' string.
 

Attachments

  • Sample.xlsx
    8.8 KB · Views: 12
  • Reply1.PNG
    Reply1.PNG
    18.5 KB · Views: 10
Administrative Note:

Welcome to the forum. :)

It has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here. Read this to understand why we (and other sites like us) consider this to be important.

As you are new, I will provide the link for you today: https://www.excelforum.com/excel-pr...expression-in-terms-of-custom-cell-names.html
 
My apology. Thank you for correcting me
 
What will I do such that D1 will have an expression of '=NewPred_1A + NewPred_1B + NewPred_1C' without manually updating the expression?
Ribbon: Formulas tab, Defined Names section, Define Name dropdown, Apply Names…, choose the names you want see in the formulae, OK.
 
Back
Top