Consulting

Results 1 to 2 of 2

Thread: Need help with a Formula Creation

  1. #1
    VBAX Contributor
    Joined
    Jun 2008
    Location
    West Midlands
    Posts
    170
    Location

    Need help with a Formula Creation

    Guys,

    I need some help please, I am trying to create a formula into a cell using assigned variables as row and column identifiers, but am at a loss on how to do it..

    The code below is what I have created but this simply returns an error message when it is run..

    ActiveCell.FormulaR1C1 = _
    "=CORREL('Data Sheet'!R[& depn1 &]C[& depc1 &]:R[& depn1 + count &]C[& depc1 &],'Data Sheet'!R[& depn2 & &]C[& depc2 &]:R[& depr2 + count &]C[& depc2 &])"


    depn1 refers to a row number
    depc1 refers to a column number
    depn2 refers to a row number
    depc2 refers to a column number
    count refers to a number

    The general idea is that I want to create the formula in a cell and the formula will utilise data from the designated points..

    What am I doing wrong?

    Thanks for you help..

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Unttested, but try

    [vba]
    ActiveCell.FormulaR1C1 = _
    "=CORREL('Data Sheet'!R[" & depn1 & "]C[" & depc1 & "]:" & _
    "R[" & depn1 + Count & "]C[" & depc1 & "]," & _
    "'Data Sheet'!R[" & depn2 & "]C[" & depc2 & "]:" & _
    "R[" & depr2 + Count & "]C[" & depc2 & "])"
    [/vba]
    ____________________________________________
    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

Posting Permissions

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