Results 1 to 8 of 8
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FUNCTION AND USE ..... (2000 sr-1)

    Assuming i have this heet (range P2:AI...)

    i want with a function to calculate the algebric summ in column AJ...

    you know:

    in all cell of this range use the sign - for all number present in column P, and the sign + for all number present in colum Q the...
    in all cell of this range use the sign - for all number present in column R, and the sign + for all number present in colum S the...
    in all cell of this range use the sign - for all number present in column T, and the sign + for all number present in colum U the...

    ecc...

    now how to use you function to have the result in .range("AJ"+count)=your_function...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FUNCTION AND USE ..... (2000 sr-1)

    Sub blahblah()
    Dim lngRow As Long
    Dim lngMaxRow As Long
    Dim dblSum As Double
    Dim lngCol As Long
    lngMaxRow = Cells(Rows.Count, "P").End(xlUp).Row
    For lngRow = 2 To lngMaxRow
    dblSum = 0
    For lngCol = 16 To 35 ' P to AI
    If lngCol Mod 2 = 0 Then
    dblSum = dblSum + Cells(lngRow, lngCol)
    Else
    dblSum = dblSum - Cells(lngRow, lngCol)
    End If
    Next lngCol
    Cells(lngRow, "AJ") = dblSum
    Next lngRow
    End Sub

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FUNCTION AND USE ..... (2000 sr-1)

    big!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    but you know i use alwys the a range similar range("AJ"+RIGA)=ecc....(RGA is my ######er)
    is possible transform this macro in function and use in this range? if yes ihow to use in range?
    Tks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FUNCTION AND USE ..... (2000 sr-1)

    When I give you a function, you want a procedure, and when I give you a procedure, you want a function... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Here is the function:

    Function AlternatingSum(lngRow As Long) As Double
    Dim lngCol As Long
    For lngCol = 16 To 35 ' P to AI
    If lngCol Mod 2 = 0 Then
    AlternatingSum = AlternatingSum + Cells(lngRow, lngCol)
    Else
    AlternatingSum = AlternatingSum - Cells(lngRow, lngCol)
    End If
    Next lngCol
    End Function

    Use it like this:

    Range("AJ" & RIGA) = AlternatingSum(RIGA)

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FUNCTION AND USE ..... (2000 sr-1)

    yes you are right...
    But after 3 year on this forum now i have understand the 70% the use of a function:-)

    Remenber:

    Sal=active.cell(0,0)
    Hans=active.cell(100000,1000000)

    is this my first consideration on you in 2003:-)

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FUNCTION AND USE ..... (2000 sr-1)

    hummm
    but why you use alway ...& RIGA insted ...+RIGA not is the same result?
    To understand, tell me.
    Tks.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FUNCTION AND USE ..... (2000 sr-1)

    You can use both + RIGA and & RIGA. I prefer to use & because that is the 'concatenation' operator for strings, while + is mostly used to add numbers. In some situations, + might not return the expected result.

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FUNCTION AND USE ..... (2000 sr-1)

    In your "Honor" i use & RIGA....

Posting Permissions

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