Setting Background Fill Color In VBA

Aug 4, 2009

I'm admittedly a novice in VBA but I'm trying to simply settnig the background color of the active cell. I've seen various snippets on the web that reference this via setting the color.index variable, using the RGB codes, etc. but nothing seems to work. I'm sure I'm missing something obvious. I know from tracing thru that the assignment instruction is being executed. I've tried using Selection.blah instead of ActiveCell, etc. also.

Select Case Total_Points
Case Is >= 70
ActiveCell.Interior.ColorIndex = vbGreen 'Green
ActiveCell.Interior.Pattern = 1 'xlSolid
ActiveCell.Interior.PatternColorIndex = -4105 'xlAutomatic
Client_Type = "Elite Partner (" & Round(Total_Points) & ")"

View 9 Replies


ADVERTISEMENT

Alternate The Background Color (fill Color) Of Rows In A Spreadsheet

Aug 19, 2009

how I can alternate the background color (fill color) of rows in a spreadsheet. Say I wanted every other row to be gray starting at row 10.

View 6 Replies View Related

Setting Background Colour

Dec 4, 2008

I am wanting to create a function, callable from a worksheet, that sets the background colour for any given range of cells to a given RGB value. I am confused about the Color and ColorIndex properties. I'd have thought the following piece of code was trivial and would work but it doesn't.

View 4 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

Count By Font Color & Background Color

Dec 12, 2007

In excel 2000, I am trying to count the lines in a spreadsheet that has the first cell in each row highlighed in yellow. Additionally, I am trying to count the number of rows that has a red font used in the cell in column D.

I have reviewed other posts by searching counting highlighted cells, but I do not understand how to complete the entire process. One of the suggestion was to create a vb script in combination with using =cellindex(??). I do not really understand how to create this, name it and the run it.

View 8 Replies View Related

Cell Fill (Background) Colors

Mar 6, 2009

when I copy a worksheet from one workbook to another, the colors on the sheet in the destination workbook, become dull/faded. They actually change from the original colors to some off colors. I copy by selecting the source sheet, hold down ctrl key, then drag from one workbook to another). Also, is there a way to get the sheet back to the original colors.

View 2 Replies View Related

Copy Cells Without Background Fill In VB

Jul 14, 2009

I currently have some code that copies a single cell from multiple worksheets. Unfortunately those cells all have a yellow fill and i don't want that fill showing up in my summary sheet. How can i alter this code to copy the cells without the fill.

View 2 Replies View Related

Change Row Background Color Using VBA

Nov 19, 2012

Try to find a way to automatically change the color of a row, based in changing the name in column A.

I tried conditional formatting but the name (or dates) in column A are not the same (always other and other).

I failed to adapt any VBA CODE (found in GOOGLE) because column A varies a lot.

Annex a photo and an excel example.

EXAMPLE FORUM HELP.jpg
EXAMPLE 1.xlsx

View 9 Replies View Related

How To Count Background Color

Apr 7, 2014

Is there a way to count the background color from a range of cell? for example: In a range of A1:B5 there are 5 cells highlighted with yellow background, the formula should give me 5 counts for yellow background.

View 11 Replies View Related

Change Background Color Of Every Second Row?

Jul 30, 2014

I have a given som (general) range where I would like a function to change the background color of every second row in a visual basic function.

One could of course just loop through it and use the mod function, but I think there has to be something quicker.

I know about conditional formatting, but it is something I need to use over and over again on Ranges that will differ in size so I would like it to be a function I can just run as part of a sub.

View 1 Replies View Related

Textbox Background Color ..

Dec 29, 2008

How can I add some code to the routine below in order to change the background color into green?

View 7 Replies View Related

How To Color The Background Cells

Aug 26, 2009

How to color the background cells using text ...

View 6 Replies View Related

Add Background Color Dropdown?

Jan 24, 2013

There is a color i like to use alot for shading cell background, and i'd like to add it to the background color dropdown. Now, i get to it by clicking "more colors" and then selecting it from that dialog. This is a lighter shade of yellow. I swear it used to be on the dropdown, but i believe it was removed at some excel version, so now its more of a hassle for me to get to it. Is this customization possible? In the macro recorder, it comes out as .Color = 10092543. Now, it will occasionally show up for a while under "recent colors" but then that will go away after a while.

View 1 Replies View Related

Sort By Row Background Color Possible

Jun 29, 2007

I have a spreadsheet that has differen color rows for certain data. Is it possible to sort a spreadsheet by row color instead of row header?

View 9 Replies View Related

Auto Format Fill Colour Background On Certain Cells

Apr 2, 2007

I have been working on a spreadsheet but I use autoformat for.

For example if the date in the cell matches today's date then it turns the text read and makes it bold.

I was wondering if there was a way to format several cells in a row if a certain criteria was met.

for example

A B C
1 Item Cost Quantity
2 Car £11,520 2
3 Bike £7,500 1
4 Tyres £50 4

Now for example if I set a condition whereas the quatity is greater than 3 then it would highlight the whole row.

So in the example above I would like to to highlight row 4 and Fill colour cells A4,B4 & C4 with a yellow background and Red Text and make the texted bold.

View 14 Replies View Related

Setting A Range Of Fill Dates

Jun 23, 2006

I have a certain number of accounts for opening and close dates. What I wish to acheive is to fill a Range of date from the opening to the closing (or up to 200606 YYYY-MM) in another spreadsheet with the account number corresponding to that date next to it.

The VBA I have right now manages to create the list of accounts but up till 2006. It isnt taking into consideration the closing dates of accounts.

So For example What I want is to set up inside of the loop that to continue to do the loop until it reaches the closing date by YYYY-MM so if the clossing date is 200504 I will have data filled up to that date, and if the closing date is "" then fill the dates up til 200606. Ive tried out a number of ways of inserting the if statement but apparently the string create a problem.

Here is my current VBA and a Sample Sheet of what it looks like....

View 9 Replies View Related

Default Background Color Is Purple?

May 4, 2009

When I open a new worksheet it is purple. The fill color bucket it defaulted to no fill. I select the entire worksheet and click on the 'no fill' and get a normal white background. If I delete anything on the spreadsheet, where the items were deleted the background is again purple. I have to select and again click on 'no fill'. I am constantly fighting this creaping purple. Just started about a week ago.

View 4 Replies View Related

Forms Button Background Color

Aug 23, 2009

Can the backround color on a forms toolbar button be changed or must I use a control toolbar button if I want the button in color? I would prefer using the forms button and have tried customizing (tools/customize/forms) then right clicking on the forms button icon and selecting “Edit button image”, clicked on the desired color and clicked ok.

View 2 Replies View Related

Return Value Based On Background Color

Mar 11, 2014

I've got a problem to write macro. I need users to color code background (manual not conditional formatting) depending of progress in projects. Then range L6:N10 will automatically return value (from range E5:I5) based on background color.

Users got very basic excel skills and their work will limit to manual background change.

I need something like INDEX MATCH based on colorindex.

View 2 Replies View Related

Count Of Red Background Color Cells

Nov 9, 2011

I am using the following formula and getting a #NAME returned

I just need the count of the red background color cells.

Code:
=SUMPRODUCT(--(ExtCell("backgroundcolor",$E$2:$E$13,1)=3))

Where E2:E13 have the values and only the red background (=3) is needed. If the green and yellow background colors where needed what do I set the = to?

View 3 Replies View Related

Add Background Color To Data In Worksheet?

May 31, 2012

i trying to write a macro to add Yellow background color to all the data starting from row 2 in a specfic worksheet but the rows of data is always different it coulsbe from row 2 to 50 then the next day from row 2 to 100 etc.

Code:
Sub Macro2()
Range("A2").Select
Range("A2:O56").Select
With Selection.Interior

[Code].....

View 4 Replies View Related

Background Color In Excel Chart?

Jul 13, 2012

How I can add background color to an excel chart. I need from left to right the 2/3rds to the chart to be light gray and the other 1/3 light blue.

View 7 Replies View Related

If Statement Dealing With Color Background

Nov 19, 2009

I am trying to write an If statement that would search a column for cells that have red as a background color, and if they did, would mark the cell with an X.

View 9 Replies View Related

Background Color In Column Chart

Dec 22, 2009

I have a column chart that goes 0-100%. The back wall is red from 0-60%, yellow from 60-80%, and green from 80-100%.

To do this, I shaded some blank cells to the same proportional shape, did a screen capture, saved that image as a file, then imported it back in as the background.

Problem is, those color breakpoints (60%,80%) may change, and that process is a pain. Is there an easier way to do this such that if I change the values the background will change automatically based on the shading of some cells?

View 9 Replies View Related

Return Background Color Of Cell

Oct 6, 2006

On one worksheet I have a list of colours in cells. I want to be able to look in the list the list and return the background colour of that cell. The function i am using is:

=CELLCOLORINDEX('1.1'!$C28,FALSE)

'1.1' is the worksheet name, $C28 is the cell (coloured blue)

It seems to work because I am getting the correct background colour in the new worksheet, however it also returns the number(37) as well.

I just want the background colour to be shown only, not the color's number as well.

Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the Interior
' (background) of a cell, or, if OfText is true, of the Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1, 1).Font.ColorIndex
Else
CellColorIndex = InRange(1, 1).Interior.ColorIndex
End If
End Function

View 9 Replies View Related

Clear Background Color Before Print

Jun 12, 2007

I have a excel file wherein background color as well as conditional formatting background color is used. However, since printout consumes huge ink for those sheets, i want that before print the code will clear all the background color (done through Fill color & conditional formatting color) and after the print activity, restore those color. the colors are given to faciliate data entry and better presentation.i have recorded the same but background is not restored when I run the code And also sometimes the code doesnot start printing.

View 4 Replies View Related

Background Color And Border Around Macro

Aug 6, 2008

I am trying to develop an Excel spread- sheet by using some macros. In detail, in my first worksheet, I have something like -

Exp1 ....
Exp2 ....
Exp3 ....
:
:
:
Expn ....

This rows are coming from another worksheet and I have used a macro (developed by me) to populate these rows. Even the number of rows to be populated is not fixed.
However, I would like to add one row with text - " Total Expense" after those rows. This row will have some background color - say Tan - and font color - say Green - and also a border around its own - in nature, the border will be thick, Double and with color Rose. I have tried the following code in macro but not working properly -

Sub Include_Fields_n_Format(loc As String)
tot_exp_scell = loc & f_scell
tot_exp_ecell = loc & (f_scell + 1)
Range(tot_exp_scell, tot_exp_ecell). Merge
Range(tot_exp_scell, tot_exp_ecell).WrapText = True

Range(tot_exp_scell, tot_exp_ecell).Interior.Color = RGB(150, 150, 150)
With Range(tot_exp_scell, tot_exp_ecell).Font...................

View 4 Replies View Related

Add A Textbox At The Current Position (selected Cell) With A Set Size, Fill Color, And Border Color

Nov 2, 2008

I'm trying to add a textbox at the current position (selected cell) with a set size, fill color, and border color. I found this: http://msdn.microsoft.com/en-us/libr...8(VS.80).aspx:

View 2 Replies View Related

Change Matched Cells Background Color

Mar 7, 2014

Macro is not working .So the macro I am using is supposed to look back at all the months tab, match the Name from previous tabs and if they match change background color of the active sheet's cell to red.

Right now the macro is only able to lookup the name in the previous tab (i.e. For December it will only lookup November tab and not October-January).

e.g. (Candidate name is Jack King and he is in (october's tab, Column A Cell 2 )

I want this candidate name to turn red once I type his name in November/December tab.

I have pasted the code I am using below:

[Code] ......

View 9 Replies View Related

Macro For Changing Background Color Of The Cells

Oct 21, 2008

I have an excel sheet in which many cells have a background color of Green. These cells are located all over the sheet. I want to change the background color from Green to Red not affecting the color of other cells in the sheet.


I will be realy really thankful, as I have to do this exercise for more than 50 worksheets.......If I start doing it manually by selecting each celll with green color background and changing it to red.....you can well imagine my condition.....my life would get shorten significantly while doing this.

View 6 Replies View Related







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