Color Banding Of Arbitrary Range

Nov 23, 2007

I know that if I select say A1:C100 on a spreadsheet, I can color alternating rows using conditional formatting and the formula =MOD( COUNTA($A$1:$A1),2). I am using COUNTA -- rather than simply ROW() -- so that I am only considering visible rows. I am trying to write a VBA subroutine that takes in an arbitrary range and colors in every other row of that range. Something like:

Sub FormatRange(ByRef theRange As Range, ByVal theColor As Integer)
theRange.FormatConditions.Delete
theRange.FormatConditions.Add Type:=xlExpression, Formula1:= "=MOD(COUNTA($A$1:$A1),2)"
theRange.FormatConditions(1).Interior.ColorIndex = theColor
End Sub

However I want to make the argument to COUNTA refer to the first column in theRange, not necessarily column A in the spreadsheet.

View 3 Replies


ADVERTISEMENT

Color Banding On Columns

Apr 5, 2012

I am trying to band columns together in two's and this formula works except for I need the banding to start with column B.

=MOD(INT((COLUMN()-1)/2)+1,2)

Example:
Column A - no banding
Column B and C - banded
Column D and E - no banding
Column F and B - banded
etc.,

Is there another solution to this without maybe adding a helper row below the data with 0 0 1 1 0 0 1 1 0 0 and do the conditional formatting based off of the helper row?

View 5 Replies View Related

Color Banding To Locate Active Cell

Mar 24, 2006

I used the method described here:
[url]

The problem is that it seems only to work on the computer on which I made the sheet. This should mean that it is somehow dependent on some local settings. Does anybody know what settings, or whether it is something else that may be the cause?

View 9 Replies View Related

Row Banding

Jul 23, 2008

i am having problems with the conditional formating function.

to make document i am working on for office a lot more clear i was hopeing to do some row banding. i think you can get some basic row banding in auto format but i was hoping to do it myself.

when i go to conditional formating - i change the tab to Formula is: ...

View 9 Replies View Related

Banding Numbers Associated Trigger Points?

Mar 4, 2014

We have a customer rebate in place with various levels of refund based on the quantity purchased during the year. I have used a sumproduct formula to calculate this before.

The customer used to have the following set up -

0-999 - £1.00 per unit rebate.
1000-1999 - £2.00 per unit rebate.
2000-2999 - £3.00 per unit rebate.

So if they bought 2501 units they would get a rebate of (1000*1)+(1000*2)+(501*3). However the customer has trigger points so rather than the above it is now -

0-999 - £1.00 per unit rebate.
1000-1999 - £2.00 per unit rebate.
2000-2999 - £4.00 per unit rebate if 2500 bought.

So now it would look like this - (1000*1)+(1000*2)+(501*4). However if they only bought 2499 units it would be (1000*1)+(1000*2)+(499*2).

View 3 Replies View Related

Conditional Formatting For Row Banding Doesn't Work After Autofilter

Sep 8, 2009

For obvious reasons, the conditional formatting to shade alternate rows doesn't work when filtered. So I think I need another way of doing it. Luckily, my table is fairly static, rows aren't added or removed. The first column is excluded from the banding. As is the first and last row with data (1 & 67) respectively. I found a relevant thread here, but the code is beyond my understanding.

View 3 Replies View Related

Return Maximum Of Active Cell & Arbitrary Value To Cell

Nov 18, 2007

I am looking for VBA that will add the value of the current active cell on the sheet to the value in cell F12. The maximum value of F12 cannot exceed 1000. So if the value in F12 = 950 and 100 is the value in the active cell the maximum value in F12 should show 1000, not 1050.

It should do this on the click of a button.

View 5 Replies View Related

Setting Color Of Range Based On Adjacent Cell Color

Nov 1, 2009

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 7 Replies View Related

Conditional Formatting - Cell Color Based On Range Of Cell Color

Aug 9, 2013

Summary of performance of various products against target is as follows,

Product vs Target
Color Code
Result

CH4OH
Green
1.0

[Code] ........

I need the final result automated as follows,

If 2 green of the 4 products, then final result Gree
If 2 Amber of the 4 products, then final result amber
If 2 Red of the 4 products, final result Red

Is there a way to automate this?

View 8 Replies View Related

Fill Color In Range Between Specified Value

Oct 29, 2007

Trying to find a way to fill in a color based on a specified value, up to the last entry.

ie. Within a range ("Range1")T1:T9, anywhere the value is "R" , fill the color red within column P (offset -5 columns to the left) up to the last entry.

..this is something I would like to initiate via button assignment using a VBA script.

eg:

Column..P,.....T

1..................B
2........Red.....R
3........Red.....T
4........Red.....R
5........Red.....V
6........Red.....M
7........Red.....R
8..................X
9..................X

View 11 Replies View Related

Max Date In Color Range

Jul 26, 2006

I have a spreadsheet (I've attached an example) that has a date stamp for when column B is updated.

What I would like is to put into cell a1, the max date/time that the yellow cells have.
This is the code that I currently have on Sheet1 to put the time stamp in.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then
Application.EnableEvents = False
Target.Offset.Offset(0, 2) = Now()
Application.EnableEvents = True
End If

End Sub

View 4 Replies View Related

Color Range Between Specified Values

Nov 21, 2007

I'm using this conditional format formula (compliments of "shg")

= COUNTIF($T$16:$T16, "R") * COUNTIF($T16:$T$600, "R")

Which fills a color (Red) based on a specified value, up to the last entry.

The conditional format is within a range ("Range1") in column P. The formula looks in column T for a value of "R" , in which it fills the cells between the first an last value with the color Red.

as a brief example:

Column..P,.....T

1..................X
2........Red.....R
3........Red.....X
4........Red.....R
5........Red.....X
6........Red.....X
7........Red.....R
8..................X
9..................X

However my workbook has become very slow.. I have several columns utilizing this conditional format .(albeit trigered by a different letter value)

Is there a way to incorporate this functionality into a macro, one which i can initiate via button assignment?

View 9 Replies View Related

How To Sort Range By Cell Color

Apr 9, 2014

I have a spreadsheet we use as a "Stock Location guide" and the critical colums are as follows, Column A = Location, Column B = Date and Column F = Material Description. The following code is what we have been using to sort the guide in order of F, B and then A :

[Code] ..........

What we want to do is swap "A" and "B" so "A" is sorted before "B" and also to change the way"A" is sorted. Certain cells in "A" are yellow and I want to be able to sort by Cell color with yellow on top.

View 10 Replies View Related

Fill Color Change With Range

Nov 24, 2008

Function BG(InRange As Range)
Range("InRange").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End Function

That so far but not quite sure why that isnt working. I want to change the fill color with a UDF that all they do is select a Range and it changes those fill colors to whatever the Colorindex may be. I didnt find anything while searching the forums with this already.

View 4 Replies View Related

Color Range With User Input

Mar 8, 2007

I have searched for code in the forum to help me here but could not get any of the possible choices to work for me. I have a spreadsheet that is password protected but would like the user to be able to change the color of the fonts based on the user's choice. The protected page (one of many in the spreadsheet) has various cells that are unlocked so that the user can enter data. The rest of the page is locked. I have allowed all users of the worksheet to Select Unlocked Cells only. I have attempted to allow them to Format cells as well, but each time the program is re opened this feature is no longer working. (The program has a macro that ensures it opens in protected mode each time.)

So I would like to set up a Macro that allows the users to set the color of 6 rows and 5 columns based on their choice. An example of the configuration is:
1234Color Choice

A11016221
B21117232
C31218243
D41319254
E51420265
F61521276

Using the above format, I am imagining the I would have a Key with color codes (using the ColorIndex Properties). The user would type in the appropriate number for each row and click a button and the rows (5 cells each) would change to the selected color.

View 9 Replies View Related

Loop Through Range By Color Index

Jun 16, 2007

I have a bit of VBA code that loops through a range and looks at the color index. If it is color index three then it will put a "1" in the cell six columns over. This code works, but I see over and over again that loops are bad and inefficient. Since I am working on my code being more efficient I wanted suggestions for altrenate code that would do basically the same thing.

Dim Bcell As Range
For Each Bcell In Range("D2:D304")
If Bcell.Interior.ColorIndex = 3 Then
Bcell.Offset(0, 6) = "1"
Else
Bcell.Offset(0, 6).ClearContents
End If
Next Bcell

View 4 Replies View Related

Color Offset Of Named Range

Dec 2, 2007

I've created a named range "Row_16" H16:M16. I've made a macro which colors the interior of this range..

Sub Fill_Row16()
Range("Row_16").Select
With Selection.Interior
.ColorIndex = 48
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End Sub

I would also like to add a secondary color (Red) to the row just below this range ie H17:M17. Is there a way to offset/ select an entire range.?

View 2 Replies View Related

Color Cells Within Numeric Range

Jan 10, 2008

Trying to make an excel macro that changes the background of a cell dependant if the value is between one number and another or equal to another number.

Cell values =
a1 = 250
a2 = 475
a3 = 715

vba Example:

Case Is > 200 and < 400
colchoice = 4
Case Is >450 and < 550
colchoice = 5
Case is >600 and <700 or = 715
colchoice = 6
If i run the macro the cell background should be
a1 =4
a2 =5
a3 =6

View 4 Replies View Related

Color Maximum & Minimum Value In Range

Feb 16, 2008

I use code as below to find max or min data row, data is in not integer, but match doesn't work, I got error 1004, "Match function's properties can't be accessd".

Sub SelectMaxMin(ByVal vSheet As Worksheet)
Dim i As Integer, oRange As Range, iRowMax As Integer, iRowMin As Integer
For i = 4 To 23
Set oRange = vSheet.Range(Chr(64 + i) & 6 & ":" & Chr(64 + i) & 82)
iRowMax = WorksheetFunction.Match(WorksheetFunction.Max(oRange), oRange) + 5
iRowMin = WorksheetFunction.Match(WorksheetFunction.Min(oRange), oRange) + 5
vSheet.Cells(iRowMax, i).Interior.ColorIndex = 40
vSheet.Cells(iRowMin, i).Interior.ColorIndex = 35
Next
Set oRange = Nothing
End Sub

View 6 Replies View Related

Color Row Range Based On Cell On Same Row

Jun 1, 2008

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 8 Replies View Related

VBA To Color Range Based On Cell Value

Aug 13, 2008

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 6 Replies View Related

Change Color Cells In Range Selected?

Aug 28, 2013

[URL] and how I could modify the conditional formatting/vba to return the same effect but for a selected range, not just a cell?

View 2 Replies View Related

Searches Through A Range And Changes Back Color To Values

Feb 11, 2014

I am doing a spread sheet for participation in a class. What I want is for whenever a student is absent, i.e. has a 0 in their point box for the day, that cell turns red. I have tried to make the .find method work but it has been uncooperative and so far and I can't seem to get it to even run. This is what I have so far:

HTML Code: 

Private Sub For_Loop_Click()
Set v = .Find(0, LookIn:=xlValues)
For Each v In [B6:B46]
Do
If v.Value = 0 Then v.Interior.ColorIndext = 3
Set c = .FindNext(c)

End If
End With
End Sub

View 2 Replies View Related

Find Next Cell In Range With Interior Color

Mar 8, 2014

I have a B2:M13 range. I would like to find a way to find the next cell with Interior.ColorIndex = 1.

For example, if position is currently B2 (so myrange(1, 1)) and the next black colored cell is on B6 (so myrange(5, 1)), I would like store 5 and 1 into variables.

So if no black background is found after current cell on the same row, look for next black background on next row.

If current cell is in row-M (the last one ** the range), for example, and there's no black background following on this row, find first black background in row-B.

View 5 Replies View Related

Changing A Range Of Cells Backround Color With Vb

Oct 20, 2008

This is my first post and i am new to visual basic in excell even though I got a little bit knowledge of visual basic access, please do not get annoyed at me for making stupid mistakes.

I wrote the following ...

View 9 Replies View Related

Msgbox If Background Color Exists In Range

Mar 11, 2009

If there are any cells highlighted in red (using the conditional formatting in excel 2003), I want a message box to pop up when they go to save saying something along the lines of, "Hey buddy, you really need to deal with this."

View 9 Replies View Related

Color Cells In 1 Worksheet Based On Range In Another

Feb 10, 2008

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 2 Replies View Related

Count Cells Matching Any Color In Specified Range

Mar 20, 2008

Im trying count cells based on the cells color. My sheet has multiple blocks filled with different colors. I have searched all of the regular sites out there for vb code related functions, but I can find one that will let me select a range of colors and a range of cells to be counted.

View 2 Replies View Related

Color Cells Within Numeric Range/Scope

May 27, 2008

I'm trying to do some sort of a league table

I have something like this with data in around 1000rows there is text in collums A B D and E.

A B C D E
1
2 100
3 60
4 30
5 20

and i would like to do this:
if value in cell x in collum C is over 80 then background color in Ax,Bx,Cx,Dx,Ex is yellow
if value in cell x in collum C is between 60-80 then background color in Ax,Bx,Cx,Dx,Ex is brown
if value in cell x in collum C is between 40-60 then background color in Ax,Bx,Cx,Dx,Ex is blue
if value in cell x in collum C is between 0-40 then background color in Ax,Bx,Cx,Dx,Ex is red

Obviously i cant use conditional formating because i have more then 3 conditions.

Does anybody know what code to use for VBA?

View 6 Replies View Related

Apply Color Code To Only 3 Columns Of Filtered Range

Oct 7, 2009

The following code filters my sheet to show only values less than 0 in column T, (column 20).

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved