Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


Format Color For Range Of Cells Based On Cell Value

I have been tasked with creating a Macro in order to help speed up a rather simple set of steps that are taken to format a spreadsheet each day. The last step, however, is not so simple. I would like to add a statement to the macro code that does that following:

Based on the value of a specific cell, color the cell and all corresponding cells within the same row (from colums A to AA) yellow. Essentially, cells in column D may have a the value "No Allocation", and if they do, I will need to format that cell yellow as well as all the cells within the same row for the colume range A to AA.

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
Format Cells Color Based On 1 Cell
I want to format a group of cells color based on the value of one referance cell. Example would be: If a1 is adn "X" the the results in cells b1 thru b10 would be green else they would be blue. Is there a way to do this using Excel 97?

View Replies!   View Related
Format Cell Color Based On Others Cells Not Being Blank
I know that I need to use Conditional Formatting, but I can't get the formula code correct.

This is what I need it to do:

If cell A2 is populated (not blank) AND cell B2 is blank, then cell B2 to be highlighted in bright red fill.

If cell A2 is populated (not blank) and cell B2 is also populated (not blank), then leave formatting as per normal

If cell A2 is blank then leave formatting as per normal

Basically, as soon as someone types anything into cell A2, cell B2 to turn red. Then once they have input something into cell B2, the red highlight can disappear. The inputs will be text, not numbers, so I can't use </>

I have tried varying circumstances of IFs, ANDs, NOTs, ISBLANKs etc and I can't crack

View Replies!   View Related
Change Range Format & Color Based On Result Of Drop-Down Choice
I'm using Excel 2007.

I have a field with a "YES"/"NO" drop-down box. There are three fields below which have some default formatting (thick purple dot-dot-dash borders). When the drop-down field is "YES", those three fields should change borders to a single thin black bottom border line.

OK... so that's the setup. And I should note here that it does in fact format properly. However, the problem I'm having is that the screen does not update / repaint with the new formatting. The thick purple dot-dot-dash borders remain, for the most part.

If I page down, then page back up, the new formatting appears just fine. When I switch from "YES" to "NO", again, the formatting changes, but the screen does not update/repaint so the only way to see the new formatting is to again... page up and then page down again.

I'm wondering if anyone knows a way to force the screen to repaint/update so that my users will see the new formatting without having to page up/down.

View Replies!   View Related
Setting Color Of Range Based On Adjacent Cell Color
This is probably elementary, but I'm struggling and would appreciate any help as I have very little excel VBA experience to draw from.

I have assembled code which changes the cell color based on a value change in Column A. Column A will contain many different groups of repeating values. This code works well and and I have been able to figure out how to limit the number of colors to only 2. The end result is each set of similar values in column A is visually grouped by one of two alternating colors.

The number rows in the data set is variable as the data set is extracted from SAP. The number of columns is fixed.

What I want to do now is set the cell color in columns B through F the same color that was assigned to the row in column A. So if cell A3 is set to colorindex = 6, then I want to set the range of cells B3 to E3 to the same color.

Here is the code I am using to set the color of the cells in Column A:

View Replies!   View Related
Format Cell Color Based On Text
On the attached, I want to make the status 3 lines conditional on the text found in another cell.

View Replies!   View Related
Color Cells Based On Color Of Preceeding Cell
I am looking for a very simple script that will achieve the following:

On the clicking of a button, Select and shade in a cell yellow, delete the yellow shading of the previous cell. The shading & selection should move up a column of cells, 1 at a time, in the following order:

From B10 to B9, then B9 to B8, B8 to B7 etc until the selection and shading is at B2. Once it is at B2 subsequent clicks will simply keep it at B2 (the top). Thus after 8 clicks the shading & selection should travel from B10 to B2, with only 1 cell being shaded yellow and selected at any one time.

View Replies!   View Related
Color Cells In 1 Worksheet Based On Range In Another
What i want to do is based on values in a worksheet row to fill the corresponding columns with black color on another worksheet. E.g i have the first row filled with 1,3,5,6,8 then i want the second worksheet on the first row to have filled with black color the 1st,3rd,5th,6th,8th columns and nothing on the others. The same goes for the entire sheet.

View Replies!   View Related
Change Font Color In A Range Based On One Cells Information
I have attached an example file.. Basically I want the text in a range to change to red if one cell="Description".

Also, I want a cell's text to turn blue if it's corresponding data in the row says "Click on Title to Follow Link"

The example file explains it a lot better..

Thanks for the help.. Sorry if this may seem like a duplicate post but I was not able to get any of the examples I searched for to work that others have posted.. Also, maybe conditional formatting would be an option here but I could not get it to work as it will only meet the first condition that comes across thats true...

View Replies!   View Related
VBA To Color Range Based On Cell Value
if you have an error on a spreadsheet, why doesnt this come under " case else" when vba is run past it? I have this simple code, but it doesnt work when the value on the spreadsheet is an error ("N/A").

Sub RQVChng()

Dim lgrow As Integer

lgrow = 7

Do Until Cells(lgrow, 5) = Empty

Select Case Cells(lgrow, 17).Value

Case 1
Range(Cells(lgrow, 1), Cells(lgrow, 18)).Interior.ColorIndex = xlNone

Case 2
Range(Cells(lgrow, 1), Cells(lgrow, 18)).Interior.ColorIndex = 6

View Replies!   View Related
Automatically Format Range Based On Formula Result Of Cells
The following code works perfect but the "change" event is only triggered when working directly on intersect range. Tried using the "calculation" event but could not figure it out. This is what I want:

1) To replace the code provided below using the calculation event
2) To only trigger the event for the row(s) where the new value was generated, not for the whole "For Each" statement
3) To use one single code for all worksheets, instead of copying the code in every working worksheet on the workbook, if feasible
4) And I would like a "second alternative", where the user of the workbook can click on a button and trigger the event on every row on the workbook that has a non empty cell within the intersect range, assuming that the intersect range column is the same for all worksheets

Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, d As Range, fc As Long, bc As Long, bf As Boolean
Set d = Intersect(Range("I:I"), Target)
If d Is Nothing Then Exit Sub
For Each c In d
Select Case UCase(c)
Case "C"
fc = 1: fb = True: bc = 4
Case "O"
fc = 2: fb = True: bc = 3
Case "D"
fc = 2: fb = True: bc = 46
Case "G"
fc = 2: fb = True: bc = 5..................

View Replies!   View Related
Color Code Cells Based On Value In Row 1 And Value In Cell
I have 16 columns (B:Q)
Row 1 contains either a number, the letter x, or the letter a.
Cells in Range("B2:Q628) contains either the letter x or is blank

If a cell in row 1 contains an x, then all cells in that column with an x has an Interior.ColorIndex of 45

If a cell in row 1 contains an a, then all cells in that column with a blank has an Interior.ColorIndex of 45

If a cell in row 1 contains has a number, then nothing

View Replies!   View Related
Change Color Of All Cells On Sheet Based Off Of One Cell Value
I want to change the fill color of all cells on my sheet, based on the value of one specific cell. In my sheet, I am using cell F1 as the trigger for the change. If the word Blue is in the cell, I want the background color of all cells to be Blue. Likewise for Red and Yellow as well. I don't believe conditional formatting can get this done, as all but the one cell (for this) will be empty.

View Replies!   View Related
Conditional Format Based On A Text Range Within A Cell
conditional format formula that is based on a text range within a cell. In my case, I would like to compare the low and high range when inputted as a number followed by the quotation marks followed by space then hyphen, space then number and ending in quotation marks. The quotation mark is being used to represent inches.

Like this in cell D14: 0.2 - 2.2

I am using the following condition format formula which works for the strict case above.

HTML =OR(D16<LEFT($D$14,3)+0,D16>MID($D$14,8,3)+0)
However, there will be times when users using this spreadsheet may leave out the spaces on either side of the hyphen, or add more than one space between the number and hyphen. Also if additional digits are added, my formula above does not include all the digits in the results. I prefer to leave the quotation marks in...........

View Replies!   View Related
Using Conditional Formatting To Format Range Based On One Cell
I am working with the Conditional Formatting, which is fine for one cell. Here is what I am trying to do: IF cell in $A1 = 1 then bold $B2:$M2 and apply solid line border to top of cell ranges. I have tried conditional formatting but it only formats the cells in column A. And I can't seem to find a BOLD statement for the cell formulas.

View Replies!   View Related
Automatically Format Range Based On Specific Cell
I am looking for VB code that will format a range of cells from a number format to a percentage format based on a reference cell. The reference cell is a drop down created from a list validation.

For example: If the reference cell (cell A1) =1 then cell range B2:C4 would be a number format. If A1 = 2 then cell range B2:C4 would be a percentage format.

I have searched for hours trying to find a relevant thread; I know they are out there, maybe I just wasn't typing in the correct search words.

View Replies!   View Related
Color Row Based On Fixed Cell & Relative Cells
My sales spreadsheets have a column which is turned to 100% when the order comes in (i.e. when the salesman gets it in his commission). I have applied conditional formatting to turn the whole row green when this happens (for ease of seeing which orders are in)

We also have a cell for the Purchase Order "number" (as these come from the customer, these can be a straight number sequence - "12345" or a mix of letters and numbers - "ABC12345"). My boss would like this cell to be red if the "order in" column is at 100%, but there is no PO number.

However, when I put in the formatting:
(1) =$K$15=1 (to turn the row green)
(2) Cell Value is equal to 0 (to turn the cell red)

it will apply (1) no problem, but will only apply (2) if (1) is false. (i.e. if (1) is true, the whole row goes green, with no red in the PO box.)

If I switch them round (i.e. have (2) first), then I get the formatting that I want (i.e. green row with a red box), but if (1) is false, I still get a red PO box.

What I need is a way of only applying (2) if (1) is true. (or any other way of only making the PO box red if the order is 100% but there is no PO number)

View Replies!   View Related
Cell Number Format Based On Another Cells Value
If Cell A1 in my spreadsheet is 1, then cell A2 should appear formatted as a percentage. So if a user enters 9000 into cell A2, it should appear as 9000%. If Cell A1 in my spreadsheet is 2, then cell A2 should appear as a comma-formatted whole number. So if a user enters 9000 into cell A2, it should appear as 9,000. Conditional formatting doesn't appear to let me do this.

View Replies!   View Related
Color Column Charts Based On Font Color Data Cells
I have attached the relevant spreadsheet for which I need to alter the color of the columns based on Site number ( Sheet 1). % Mortality will be represented in the Y-Axis, and the Site numbers would be on the X-Axis. All columns (% Mortality) except one will be of the same color, and the one of a different color will indicate a specific site. As an example, site 86 is colored differently. The way I require the chart to look is shown on Sheet 1.

After reading through some great posts on Ozgrid, I managed to do this using conditional formatting (Sheet 2), but that sort of falls short because I am required to add a data table to the chart, and the parameter that is indicated by the column bars happens to appear twice in the data table.

I was wondering if this can be automated maybe using VBA, but with the possibility of simply matching the color of columns with the font color of respective entry in the data series.

View Replies!   View Related
VBA - Format Range Font Based On Value In A Reference Cell
I am preparing a model for a client that runs excel 2003. I need to change the format of a range based on the value in a cell (reference cell) that is outside the range to be reformatted.

Reference cell is a named cell with the value calculated with a Match() function, the only possible values are (1, 2, 3).

I need the VBA code to retrieve the reference cell value and apply one of three formats to the range. I believe the code for that part is something like:

Private Sub Format_Font()
Set vrange = Range("d63:r63")
Set refrange = Names("ind_agentfee").RefersTo
Set refrange = Mid(refrange, 2)
On Error Resume Next
If refrange = 1 Then
With vrange.Font
.Style = "Comma"
.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"
If refrange = 2 Then
With vrange.Font
.Style = "Comma"
.NumberFormat = "_(* #,##0_);_(* (#,##0);_(* ""-""??_);_(@_)"
.Style = "Percent"
End If
End Sub

I am having problems getting the proper opening statements and declarations correct and also get an "Else without Then" error with all combination's that I am attempting. I am sure that the code is mess now as I started with a recorded macro then modified it multiple times while researching the web.

View Replies!   View Related
Format Border Color Based On Value
I found this code (compliments of Andy Pope) which fills a background color based on its corresponding cell value. (then offsets all uniformly)

View Replies!   View Related
Macro To Color Cells Based On Their Font Color
I have a spreadsheet that i download from the net daily, which is seperated into columns of information.

I want to be able to look down a column and mark a cell in a seperate column if the cell font text is red.

For example looking down column A ... if the font text of a1 is red then mark the cell background colour of T1 red - if a2 text colour is red then mark the cell T2 red .... etc etc.

If the font colour in a1 or a2 ... etc etc is any other colour then do nothing.

I have 5 columns I wish to look down and mark in 5 seperate columns - I have tried to do this by conditional formating but don't know the fomula for checking font colour.

View Replies!   View Related
Conditional Format Based On Background Color
I'm attempting to write a conditional format formula that will change the background color based on multiple color options on in a row. I have cell A:c as first, last and middle name. I utilize the rest 40+ cells that provides dates that are conditionally formatted to based on dates. I've approached this trying to reference the columns dates and cannot figure it out. Heres what I would like to do:
If any cell in from D:Z has a background color of red, yellow, green, and none it will change the background color in cells A:C. Its easy to reference one cell but not multiple. I've attached a sample of what I would like to do and I manually changed to cells A:C to show how I would like to show my results.

View Replies!   View Related
Color Cell Fonts Based On Text Color Of TextBox Controls On UserForm
I have got a userform with lots of controls,

One of the action's on a large group of the controls is the same but except for one number

here is an example

If TextBox107.ForeColor = 255 Then ActiveCell. Offset(0, 53).Font.ColorIndex = 3
If TextBox108.ForeColor = 255 Then ActiveCell.Offset(0, 54).Font.ColorIndex = 3
If TextBox109.ForeColor = 255 Then ActiveCell.Offset(0, 55).Font.ColorIndex = 3

This makes a cell that correlates to the textbox red if the text in the textbox is red.

Now, I loads of these textboxes that all need to run the same code with just the Offset value one digit higher than the last and I was hoping I could create a loop to avoid a huge block of code but I can't work out how to make a constant that will +1 with each loop.

Also, can I assume that a loop will start with the control with the lowest number i.e. Textbox1 and then work its way through the rest of them in order?

View Replies!   View Related
Change Font Color Based On Adjacent Cell Color
I have two columns. The first one (A) contains cells that have different Fill colors. The second column (B) contains text adjacent to the colored cells. I am trying to change the color of the text in the second column (B) to the corresponding color in the adjacent cell in the first column (A). I don't think conditional formating works well in this situation. I believe the solution would be some sort of macro.

View Replies!   View Related
Change Text Color Based On Cell Color
I have various row cells in column (F) filled with the color Green. And corresponding text in Column G. How can I change the text of that particular row to white.

i.e.: if any cell in column F is Green, change the text color of that row in Column G to white?

View Replies!   View Related
Color Row Range Based On Cell On Same Row
I have an excel sheet in which i have a cell A11 with drop down list values=YES/NO.
Now based on the value in this cell i want to fill color in the cells(B1 to B10) i.e for e.g. if i select YES in the cell A11 then the cells(B1 TO B10) should become green in color.

Attached is an sample of what i want.

View Replies!   View Related
Count Conditional Format Color Cells- Used Gantt Code
I've created a Gantt chart using the tip #58. Now how can I count all the cells that are colored?

View Replies!   View Related
Color Cells Based On Adjacent Cells Being Empty & Add Text
Im trying to make my life a bit easier, by adding a few macros and formulas to the spreadsheet (Everything was done completely manually before I got here!!!).
What I would like to do is take two columns, which contain a start and end time for work shifts, and colour them GREEN once I have entered a name in the Worker column (Along side the two with the time), and also to fill a cell with a Yes or a No. Im aware of auto conditioning, and Ive tried to have a play to get this to work, but I just cant work it out.
I have posted a link to an image which shows what I want. I hope I've explained it well enough!

View Replies!   View Related
Fill Cells Color In Worbook Based On Other Cells
how can I automatically fill cells with certain colors based on the value of the cell. (i.e. I want to search an entire workbook and fill cells with values between 80 and 99 green, 60 to 79 yellow and 0 to 59 red.)

View Replies!   View Related
Color Cells Based On Multiple Conditions Of Different Cells
Im trying to change color in cell B9 according to different conditions in Cell C9 (than on b10 according to c10 and so long until necessary - probably will be around 2000 lines). Since there are more than 3 conditions and in two cases condition depends on the color of the C Column, I can not use conditional formatting. Ive searched and found similar forums here, but since Im ignorant in VBA code, I couldnt manage to make adjustments. So if you can help me with the code, I would really appreciate it!

Condition and Results required would be:

IF column C = S than on Column B = color cell light blue with white border
IF column C = P than on Column B = color cell Green with white border
IF column C = A than on Column B = color cell Yellow with white border
IF column C = L than on Column B = color cell Red with white border
IF column C = C than on Column B = color cell Dark Blue with white border
IF column C = than on Column B = color cell white
IF column C = V and has white background than on Column B = color cell white
IF column C = V and has a Dark Grey background than on Column B = color cell Dark Grey

I dont know if the last two are feasible.

View Replies!   View Related
Change Cell Format Based On Existing Currency Format
I would like to have a single button that changes a range of cells from the USD to EURO to perhaps CAD symbol. Can this operation be performed, such that if I start in dollars, and I click the button once, it shifts by range to EURO (not formulas...just symbol)...and then if I click the same button again, it goes to CAD, and then back to USD with a third click?

View Replies!   View Related
Using 'IF' With Conditional Format (change Cell Color Based On The 'P' Or 'F')
My cell has a 'P' or an 'F' plus some additional text. I'm trying to change cell color based on the 'P' or 'F' but I can't get it to recognize the letters.
Samples of what I've tried:

I can 'FIND' the 'P' or 'F' but there may be a P or F else where in the cell so the color may come up incorrect. I'm trying to get it to just look at the first character in the cell. Can the 'IF' be used with CFs?

View Replies!   View Related
Colour Range Of Cells In A Row Based On Value Of One Cell
I would like to change cells A2 to G2 to a different colour based on the value of G2

(0 to 48) Dark Green
(-2) Light Green
(-4) Yellow
(-6 to -48) Red

The range of the sheet would be A2 - G130. Each Row would change on value of cells in Column G.

View Replies!   View Related
Move Range Of Cells Based On Cell Criteria
I'm trying to do is loop through a range of cells, and if the cell meets a condition I want to move it and 2 cells to the right of it left by one cell.

Sub MoveRangeOfCellsBasedOnCellCriteria()
Dim myrange, cell As Range
Set myrange = ActiveSheet.Range("H2", Range("H65536").End(xlUp))
For Each cell In myrange
If IsNumeric(Left(cell.Value, 1)) _
Or Left(cell.Value, 5) = "UNIT " _
Or Left(cell.Value, 4) = "THE " _
Or Left(cell.Value, 5) = "FLAT " Then
cell.Offset(0, -1).Range("A1").Select
cell.Offset(1, 1).Range("A1").Select
End If
Next cell
End Sub

View Replies!   View Related
Macro To Format Half Of The Cell With A Different Color
I have a list of records that will eventually be used to create a pivot table. Sometimes an account number will be listed twice but instead of adding to the previous info, it needs to start a new record. I decided in these instances to mark the account number with a character (+). Even though the + will designate a separate record, I'd like it to be invisible.

Is there a way to automatically turn the font color white for only the +? Since I've automated the rest of the process using a macro, a VBA solution is fine.

View Replies!   View Related
Color Format A Portion Of Text Within A Cell
I have a column of data that contain miscellaneous comments in each of the cells in column 'A'. This is a sample of the text in one of those cells:

The quick brown fox jumps over the lazy dog.
Is there a way to programmaticly search each cell in col 'A' to look for any occurrence of the string 'fox jumps over' and highlite in RED only that string occurrence?

So in the end the above cell would now be:

The quick brown fox jumps over the lazy dog.

View Replies!   View Related
Color Cells Based On Others
I have a long standing problem, i need to use some code that will search a range of cells , say j1 to j15, for a text "ship", gather the value from the equivalent h column cell and then use that value in futher code to colour some cells. So if the value returned is say 5, then colour the next 5 columns from column A whenever "ship" is typed.

View Replies!   View Related
Color Cells Based On Value Above/Below
I have many cells in a column, where I would like to change the colour depending on the value in the cell above. If one cell is more than or equals 600 000 and the cell below is less than 600 000, then the lower cell should change colour to red.
This should be repeted for all cells in the column, until the last empty cell.

Sub macro()
x = 7
Do While Cells(x, 4).Value <> ""
If Cells(x, 4).Value >= 600000 _
And Cells([x + 1], 4).Value < 600000 Then _
Cells([x + 1], 4).Select _
Selection.Font.ColorIndex = 3
End If
x = x + 1
End Sub

For this code I receive the error code "Compile error: End if without block if".

View Replies!   View Related
Color Cells Based On Difference Between Two Cells
I have a 2 lists of manually entered values where the values in each row are related. They are related in the sense that if the difference between them is equal to or less than, a given amount then the cell containing one value is colored Blue. e.g.

COl A holds Value x while COl B holds value y. I need to check which value is entered in columns A and B and if a given difference or greater exists colour the cell in COl B. For example the relationship relevant to a COL A value of 21.0 is 11.0.

So, I enter the following;

A1 B1

21.0 13.0 <----------------No color Blue

I enter new values

21.0 9.5 <----------------B1 is blue.........................

View Replies!   View Related
Populate A Specific Range Of Cells Based On A Value Of Any Kind In A Header Cell
I need to populated a specific range of cells based on a value of any kind in a header cell. Attached is a sample of the end results. Please remember each header cells needs to determine what happens the range of cells below the header cells.

View Replies!   View Related
Copy Cells Based On Color
i have att a workbook with 2 command buttons on sheet "quote"
one turns the selected cell red.
the other one i would to have select the red cells then copy to sheet1 then change the color back to white

View Replies!   View Related
Format Cells Based Upon Being Outside Scope Of Calculation Of 2 Cells
I am comparing a set of common variables across 2 sets of independent financial data. When comparing a variable across the 2 sets e.g. profit I want to colour a neighbouring cell based on the size of the difference. For example if the difference between the two values is within plus or minus 1 make it green, plus or minus 5 red etc.

View Replies!   View Related
Count Cells Based On Font Color
Hi, I've been cracking my head for a few days your assistance is much appreciated.


The ones in red is conditionally formatted. So I want at the end of each row to count how many are in red.

View Replies!   View Related
Color Rows Based On Cells Being Greater Than/Less Than X
I have a sheet contains information about employees absence:

- Staff number
- Staff name
- Date of Leave
- Date of Return
- Number of Days Lost

View Replies!   View Related
Returning A Row Of Cells Based On A Color
I am having a bit of a problem writing a formula that works under the specific conditions that I need.

I have a range of 6 cells, A1:A6 which contain text
I have formatting that turns that row red based on specific conditions. The problem is that if A1:A6 is red, I then need the text in those cells to be copied to Sheet 2 B1:B6.

View Replies!   View Related
Macro To Color Cells Based On Criteria
Column DColumn EColumn FTarget %DifferenceCash4%5.12%Large-Cap8.5%1.73%Commodities4%-1%

I need to color code Col F based on the following criteria:

If F2/E2>20%, then shade pink else no color. I only care about the absolute values. The 20% number can change depending on the category. So for commodities, the limitation is 30%. Like that I have a list of about 20 asset classes, 14 of which have the 20% constraint, rest are either 25% or 30%. I would like the cell color to be updated each time I import a file. Also I have other conditional formatting on Col F (like red color if negative number) so I don't know if another conditional format will work on the same cells?

View Replies!   View Related
Copy Cells Based On Fill Color
i have some problem in display the highlight cell to another worksheet. Below is in module, i would like to display the highlighter cell to another worksheet.

Sub Macro1()
' Macro1 Macro
' Macro recorded 9/2/2006 by user

ActiveWindow.SmallScroll Down:=-12
ActiveWindow.ScrollRow = 1

View Replies!   View Related
Deleting Cells Based On Font Color
I am trying to delete certain cells within a range of data (A13:E29) that have white font or #N/A's. The only information I need is the black data. I have to manually go and clear these cells for many different ranges. I'd like to incorporate a macro that analyzes the range first to delete the values that are white font or #N/A.

View Replies!   View Related
Color Fill Cells Based On Value Being Between 2 Values
create formula/condition to colour fill different cells based on multiple Criteria.

View Replies!   View Related
Sum Cells Based On Color Index
I am trying to use a function kindly listed by Dave, that allows for a SUM to be done on cells which have a certain color index. I have modified it very slightly, but unable to set the call to it without getting errors, perhaps someone can shed some light on what i am doing wrong. Dave's original code is

Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell,vResult)
End If
Next rCell
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function.......

View Replies!   View Related
Copyright 2005-08, All rights reserved