|
-
Dec 25th, 2012, 04:02 PM
#1
Thread Starter
PowerPoster
[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.
-
Dec 25th, 2012, 06:13 PM
#2
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
-
Dec 25th, 2012, 07:17 PM
#3
Thread Starter
PowerPoster
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.
-
Dec 25th, 2012, 09:15 PM
#4
Re: Sum of 2 rows (Used Range), check negative (VBA)
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
-
Dec 26th, 2012, 04:40 AM
#5
Thread Starter
PowerPoster
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.
-
Dec 26th, 2012, 06:08 AM
#6
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
-
Dec 26th, 2012, 07:02 AM
#7
Thread Starter
PowerPoster
Re: Sum of 2 rows (Used Range), check negative (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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|