+ Reply to Thread
Results 1 to 4 of 4

Thread: syntax for value of a variable containing address in formula

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    5

    syntax for value of a variable containing address in formula

    Trying to figure out how to use a variable, which contains an address of a value, in a formula.

    In the MTBF section i want the formula to divide by Fr which is a variable containing an address. I want the value of that address used in the formula.

    Dim Fr As Long
            Fr = Cells(Rows.Count, "K").End(xlUp).Row + 1
            Cells(Fr, "K").Formula = "=SUM(K1:K" & Fr - 1 & ")"
            'selects last row of data in 'Failure Rate' column and calculates the sum
            
            Dim MTBF As Long
            MTBF = Cells(Rows.Count, "L").End(xlUp).Row + 1
            Cells(MTBF, "L").Formula = "=1/ Fr"
            'selects last row of data in 'MTBF' column and calculates 1/sum
    Last edited by Dewy; 11-10-2010 at 10:34 AM.

  2. #2
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,228

    Re: syntax for value of a variable containing address in formula

    To make the formula work, you can put:

    Cells(MTBF, "L").Formula = "=1/" & Fr

    But if you want the value in column K that you just calculated, you'd need to put:

    Cells(MTBF, "L").Formula = "=1/" & Cells(Fr, "K").Value

    Regards

  3. #3
    Registered User
    Join Date
    11-04-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: syntax for value of a variable containing address in formula

    Thank you for the reply, but i was asking more along the lines of obtaining whatever the value of the address would be, not just the value. However solved it with this...

    Dim MTBF As Long
            MTBF = Cells(Rows.Count, "L").End(xlUp).Row + 1
            Cells(MTBF, "L").Formula = "=1/L" & Fr & ""

  4. #4
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,228

    Re: syntax for value of a variable containing address in formula

    OK, glad you got what you needed.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0