[RESOLVED] Editing the string in a cell that refers to another cell.
I have a spreadsheet in which the content’s of a cell refers to another cell e.g.
Cell A1 content’s are “=b2” . I need to write a program in which I can edit the string “=b2”. The question I have is what property (or keyword) do you place after Cells(1,1).??? To get the string “=b2”?
Cells(1,1).FormulaR1C1 almost works but it returns the string “=R2C2”. Strangely Cells(1,1).FormulaA1 generates an error message altogether (This method or property is not supported). Can anyone help me out?
Re: Editing the string in a cell that refers to another cell.
nothing.
Code:
Cells(1, 1) = "=B2"
Works just fine for me...
It is always a good idea to include the full path to the cells.
Code:
Workbooks("Test").Worksheets("Sheet1").Cells(1,1) = "=B2"
You can also do it in your code, rather than making the cell equal to another cell:
Code:
Workbooks("Test").Worksheets("Sheet1").Cells(1,1) = Workbooks("Test").Worksheets("Sheet1").Range("B2")
Re: Editing the string in a cell that refers to another cell.
After too much searching I finally found the mystery property: FormulaLocal. In case you're wondering it is "buried" in Properties of Range Objects in the Office 2007 online Help. (Don't ever waste your time searching for cell contents or cell properties or anything for that matter that has the word cell in it - they are all dead ends!) Take care and thanks anyway
Re: Editing the string in a cell that refers to another cell.
there is also
cells(1,1).formula
formulalocal takes into account special settings used in different locales, so may be slightly different, depending on excel /windows language settings
Re: Editing the string in a cell that refers to another cell.
Sorry, I misunderstood what you were asking for.