Consulting

Results 1 to 7 of 7

Thread: using formula in coding

  1. #1
    VBAX Mentor
    Joined
    Sep 2007
    Posts
    405
    Location

    using formula in coding

    Hi,

    i want to use the below formula in coding for the till the last used in a sheet.

    IF(NOT(ISNA(MATCH(1,($F2=$A$2:$A$21)*($G2>=$B$2:$B$21)*($G2<=$C$2:$C$21),0 ))),INDEX($D$2:$D$21,MATCH(1,($F2=$A$2:$A$21)*($G2>=$B$2:$B$21)*($G2<=$C$2: $C$2 1),0)),"")

    can i get assistance

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    The ... till the last used ... what?
    ____________________________________________
    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 Mentor
    Joined
    Sep 2007
    Posts
    405
    Location
    Hi,

    Till the last used row in column A of the sheet.

    -sindhuja

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You need to set up dynamic named ranges such as column A with a formula of

    =OFFSET($A$2,0,0,COUNTA($A:$A)-1,1)

    and
    =OFFSET($B$2,0,0,COUNTA($A:$A)-1,1)

    etc. and use these names in the formula.
    ____________________________________________
    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 Mentor
    Joined
    Sep 2007
    Posts
    405
    Location
    I tried with the below coding. The results are not expected.

    I guess the error is with the part. RC[-2] is considered as constant. Can you assist to make RC[-2] as dynamic

    [vba]
    Sub test()
    With Worksheets("Sheet1")
    r = .Cells(.Rows.Count, "F").End(xlUp).Row
    With .Range("i2:i" & r)
    .Formula = "=SUMIFS(c[-5],c[-8],RC[-3],C[-7],""<=RC[-2]"",c[-6],"">=RC[-2]"")"
    '.Value = .Value
    '.Copy
    '.PasteSpecial Paste:=xlPasteValues
    End With
    End With
    End Sub
    [/vba]

    sample sheet attached for reference.
    Attached Files Attached Files

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You must be talking to someone else then, because that has no relation to what I suggested.
    ____________________________________________
    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

  7. #7
    VBAX Mentor
    Joined
    Sep 2007
    Posts
    405
    Location
    Tried with the formula given in the coding before trying the one which I gave in the initial post. But doesnot work out for me.
    Last edited by sindhuja; 05-16-2012 at 05:12 AM.

Posting Permissions

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