Consulting

Results 1 to 5 of 5

Thread: Return values from formula range

  1. #1
    VBAX Regular
    Joined
    Jul 2005
    Posts
    19
    Location

    Return values from formula range

    I need to return the values from the range shown below
    and not just the formulas.

    objExcel.Range("A1:BO1").FormulaR1C1 = "=RIGHT(R[1]C,10)"
    Any help appreciated.

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    Quote Originally Posted by psauber
    I need to return the values from the range shown below
    and not just the formulas.

    objExcel.Range("A1:BO1").FormulaR1C1 = "=RIGHT(R[1]C,10)"
    What exactly are you trying to achieve?

    The code you give sets the formula in those cells, it does not return them.

    To get a value, you would just read it

    myVar =  objExcel.Range("A1").Value
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jul 2005
    Posts
    19
    Location
    Thanks for your reply.
    The code returns what is in row 2 ie. RIGHT(R[1]C,10)
    but as a formula. What I want is the absolute value of row 2 not the formula
    but I only want the 10 characters from the right as shown above.
    I hope I have clarified sufficiently.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    Quote Originally Posted by psauber
    The code returns what is in row 2 ie. RIGHT(R[1]C,10)
    but as a formula. What I want is the absolute value of row 2 not the formula
    but I only want the 10 characters from the right as shown above.
    I hope I have clarified sufficiently.
    I am sorry, but that is not what the code does.

    The code inserts a formula in all of the cells A1:BO1. That formula returns the right-most 10 characters of the cell below. So if a cell a2 contains "THis is a very long text", A1 will show " long text".

    Just occurred to me that you might mean that you want create the value in those cells, not the formula, if so, try this


    With objExcel.Range("A1:BO1")
            .FormulaR1C1 = "=RIGHT(R[1]C,10)"
            .Value = .Value
        End With
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Jul 2005
    Posts
    19
    Location
    Brilliant Xld.
    May I ask you one other question. I will start a new
    thread since the problem is slightly different.

Posting Permissions

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