Consulting

Results 1 to 10 of 10

Thread: subtraction

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    subtraction

    hi
    how can i make a subtraction between 2 lines after making auto filter
    write the results on adifferent sheet and each time when i choose a different data in the filter i see the subtraction results in the same place


    thanks

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Too obscure
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    hi
    i do not know how to explain any better

    i have an auto filter each time i choose a number 2 rows com up it actually a measurement results i just want to see the deference between them

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Oleg,

    Malcom is of course correct. If you are having a hard time 'painting a verbal picture', why not attach a tiny example wb showing us what you mean?

    Mark

  5. #5
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    hi
    see attached file in the data column i choose the serial number and under 'deferese" i must see the diferese between 2 rows or lines

  6. #6
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    What does "deferese" mean?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    I've had a third look at your workbook and still cannot understand what it is that you are chasing.

    Which two lines are you chasing to subtract? You currently have a data range of B3:R112 which you filter based on a selection in cell R2.

    There is some data existing in Column S and in range U113:AJ113 as well as B3:R112.

    How does this data relate to each other?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    Hi
    When I choose the serial with filter in cell r2 I have two answers those two line I am trying to
    subtract column by column meaning what I column b must be substracted one from the
    Other and so on.
    The answer to the substruction will be written uner the header "deferences" each time I choose
    The diferent serial in r2 cell the deferense changes.

  9. #9
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    oleg, I am getting very frustrated here with your responses. Using the data sheet you supplied as the example, your current filter value in cell R2 is 7180 and has enabled row range B22:S22 and B43:S43 to be visible.

    As I currently understand your request, you would like these two ranges to be subtracted from each other, and the resultant values to be written under the heading of "Deferense" in the range U113AJ113.

    One has 18 values and the other one has 16 values, so which values do not count?

    Currently the value in cell U113 is derived from a formula "=B3-B9" , yet we cannot view what values these are because we cannot see the data to which this formula works upon.

    Am I also correct in assuming that when saying "Deferense" you might mean "Difference"
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  10. #10
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    i see
    i started a code to do the substraction in column "p"
    what you think:
    [VBA]Sub substr()

    Dim k As Double
    Dim i As Long, y As Long, h As Long
    y = Sheets("sheet2").Range("p65536").End(xlUp).row
    myvar = Sheets("sheet2").Cells(y, 16).Value
    m = y - 1
    h = Sheets("sheet2").Range("p" & m).End(xlUp).row
    myvar2 = Sheets("sheet2").Cells(h, 16).Value
    k = (myvar2 - myvar)

    End Sub
    [/VBA]

Posting Permissions

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