Results 1 to 7 of 7

Thread: [RESOLVED] Sum of 2 rows (Used Range), check negative (VBA)

  1. #1

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Resolved [RESOLVED] Sum of 2 rows (Used Range), check negative (VBA)

    Not sure how to describe this but I'll give it a go:

    If have 3 Columns: A, B C

    Example:

    * A B C
    1 5 4
    2 7 1
    3 3 7
    4 2 1

    Now I want to do a sum of Col.A MINUS Col.B >> Answer in Col.C >> If Col.C is negative, then color.
    When using my example, Row 3 should be colored.

    I hope someone understands what I'm trying to do.

    Thanks in advance.
    Last edited by Radjesh Klauke; Dec 25th, 2012 at 07:17 PM.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Sum of 2 rows (Used Range), check negative (VBA)

    your description and example do not seem to match
    else i completely misunderstand what you want

    AB and C are normally considered to be columns rather than rows
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Sum of 2 rows (Used Range), check negative (VBA)

    Yes, sorry. I meant to say: Columns, instead of rows. You are correct. I changed it.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Sum of 2 rows (Used Range), check negative (VBA)

    Row 3 should be colored.
    you can use conditional formatting for this, but why (in your example) row 3?

    i can not see any relation to the values of columns a and b, in column C
    or is column c some other value, and only in the totals row is it relative to columns a and b?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Sum of 2 rows (Used Range), check negative (VBA)

    The value of C3 will be -4. (C3= A3-B3) Since it's negative I want it to be colored.

    Forget Column C

    Let me try to explain it better.

    There are 2 columns: ("D: D") & ("F:F")

    I want to color the row when D1..etc NIMUS F1..etc is negative.
    I need to do this for the UsedRange, since the range is never the same.

    Hopefully this explanation is better.

    Thanks in advance.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Sum of 2 rows (Used Range), check negative (VBA)

    I need to do this for the UsedRange, since the range is never the same.
    look into using conditional formatting for the entire sheet
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Sum of 2 rows (Used Range), check negative (VBA)

    Thanks for the tip.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

Posting Permissions

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



Click Here to Expand Forum to Full Width