Excel Guru's - help please!
#1
![Red face](https://www.scoobynet.com/images/icons/icon11.gif)
Ive got an excel formatting problemo.
I've got 3 columns with numbers (in my case its stock totals by location). Each is added to create a total (stock). Someone has used this - and decided that they want some of the items from the three columns - and has highlighted various rows/columns in green. I therefore need to create a new total column that excluded anything in green.
Is there a format / IIF command you can use in a new cell that checks to see if the row is not green, and if not adds itself to the total?
Thanks guys!
Jza
I've got 3 columns with numbers (in my case its stock totals by location). Each is added to create a total (stock). Someone has used this - and decided that they want some of the items from the three columns - and has highlighted various rows/columns in green. I therefore need to create a new total column that excluded anything in green.
Is there a format / IIF command you can use in a new cell that checks to see if the row is not green, and if not adds itself to the total?
Thanks guys!
Jza
#2
Scooby Regular
Join Date: Jun 2002
Location: Perth, Western Australia
Posts: 1,866
Likes: 0
Received 0 Likes
on
0 Posts
![Default](https://www.scoobynet.com/images/icons/icon1.gif)
Jza
This is very rough but might point you in the right direction. First off, I can't see how it can be done with a formula. I put some numbers in col A then defined a range for that list (called col1). Then I've attached a bit of code shown below to the worksheet_change and worksheet_selectionchange events (not sure if they are both necessary):
Application.EnableEvents = False ' this is here to stop endless loops
Dim r As Range
Dim i As Integer
Dim j As Single
Dim k As Single
Dim l As Single
Set r = Range("col1") ' the range defined on your spreadsheet
j = 0 ' initialise the variables
k = 0
l = 0
For i = 1 To r.Rows.Count
If r.Cells(i, 1).Interior.ColorIndex = 6 Then 'yellow
j = j + r.Cells(i, 1).Value
ElseIf r.Cells(i, 1).Interior.ColorIndex = 5 Then 'blue
k = k + r.Cells(i, 1).Value
ElseIf r.Cells(i, 1).Interior.ColorIndex = 4 Then 'green
l = l + r.Cells(i, 1).Value
End If
Next i
Cells(25, 1).Value = j 'three cells to hold the totals
Cells(26, 1).Value = k
Cells(27, 1).Value = l
Application.EnableEvents = True
If you want to use different colours you'll have to change the ColorIndex values.
HTH
Mark
This is very rough but might point you in the right direction. First off, I can't see how it can be done with a formula. I put some numbers in col A then defined a range for that list (called col1). Then I've attached a bit of code shown below to the worksheet_change and worksheet_selectionchange events (not sure if they are both necessary):
Application.EnableEvents = False ' this is here to stop endless loops
Dim r As Range
Dim i As Integer
Dim j As Single
Dim k As Single
Dim l As Single
Set r = Range("col1") ' the range defined on your spreadsheet
j = 0 ' initialise the variables
k = 0
l = 0
For i = 1 To r.Rows.Count
If r.Cells(i, 1).Interior.ColorIndex = 6 Then 'yellow
j = j + r.Cells(i, 1).Value
ElseIf r.Cells(i, 1).Interior.ColorIndex = 5 Then 'blue
k = k + r.Cells(i, 1).Value
ElseIf r.Cells(i, 1).Interior.ColorIndex = 4 Then 'green
l = l + r.Cells(i, 1).Value
End If
Next i
Cells(25, 1).Value = j 'three cells to hold the totals
Cells(26, 1).Value = k
Cells(27, 1).Value = l
Application.EnableEvents = True
If you want to use different colours you'll have to change the ColorIndex values.
HTH
Mark
Last edited by markr1963; 20 February 2004 at 12:47 PM. Reason: Typos
#3
![Default](https://www.scoobynet.com/images/icons/icon1.gif)
Originally Posted by Jza
Ive got an excel formatting problemo.
I've got 3 columns with numbers (in my case its stock totals by location). Each is added to create a total (stock). Someone has used this - and decided that they want some of the items from the three columns - and has highlighted various rows/columns in green. I therefore need to create a new total column that excluded anything in green.
Is there a format / IIF command you can use in a new cell that checks to see if the row is not green, and if not adds itself to the total?
Thanks guys!
Jza
I've got 3 columns with numbers (in my case its stock totals by location). Each is added to create a total (stock). Someone has used this - and decided that they want some of the items from the three columns - and has highlighted various rows/columns in green. I therefore need to create a new total column that excluded anything in green.
Is there a format / IIF command you can use in a new cell that checks to see if the row is not green, and if not adds itself to the total?
Thanks guys!
Jza
(This additional column could be hidden from view if required)
Buck
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
bluebullet29
General Technical
9
05 October 2015 02:17 PM