Results 1 to 5 of 5

Thread: [RESOLVED] Editing the string in a cell that refers to another cell.

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    6

    Resolved [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?

  2. #2
    Hyperactive Member
    Join Date
    Oct 2010
    Location
    Indiana
    Posts
    457

    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")

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    6

    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

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    Hyperactive Member
    Join Date
    Oct 2010
    Location
    Indiana
    Posts
    457

    Re: Editing the string in a cell that refers to another cell.

    Sorry, I misunderstood what you were asking for.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width