VBA Colouring Cells

Oct 10, 2008

I have a spreadsheet that contains data I import from various sources. Once the import is complete I need to colour various cells based on their contents. Normally I'd use conditional formatting, but there are more than 3 conditions so I need to use VBA (preferrably that i can turn into a macro and assign to a button to click once I've finished the imports each time)

eg: Everytime a cell content is the word "RED" , colour it red - then the same with various other colours.

Google has found me a change event piece of code but it doesnt work when you're cutting and pasting some info.

View 9 Replies


ADVERTISEMENT

Colouring Non-contiguous Cells With VBA

Dec 4, 2012

I have a rather large database that I'm trying to automate colours in, based on data that is inserted into Column 'D'. I've used the following code (with some success), but it colours columns that I don't want to colour:

VB:
Sub KeyCellsChanged()
Dim Cell As Object
For Each Cell In Range("D1:D5000")

[Code].....

That works fine - but the problem I have is that I only want to colour columns A:N, Q, T, V, AB:AE, etc. (random columns and not always together). I have already tried to replace parts (as follows), but get all sorts of errors (in particular Run-time error 1004):

VB:
If Cell = "Rabbit" Then
Cell.Range("A:N,Q, T, V, AB:AE").Interior.ColorIndex = 42

Is there someway that a line of code can determin which cells to colour in the row, or alternatively code that will colour the columns a specific colour and make them stay that colour when the first code above is used?

View 3 Replies View Related

Colouring Specific Cells Using VB

Dec 22, 2006

how I might be able to colour certain cells in a row a specific colour when a specific value is input.

For instance:
The value "A" is put into row A1. A1 and C1 cell colours change to green
The value "B" is put into row A2. A2 and C2 cell colours change to orange
etc. (not sure how many colours yet)

I sort of have a script set up, but there are certain things I dont know how to do. Like target the specific cells that need colouring.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 0 Then Exit Sub
Select Case Target.Value
Case "A"
Target.Interior.ColorIndex = 1
Case "B"
Target.Interior.ColorIndex = 2
Case "C"
Target.Interior.ColorIndex = 3
Case Else
Target.Interior.ColorIndex = 0
End Select
End Sub

View 9 Replies View Related

Colouring Many Cells, Depending On The Value Of One

Mar 28, 2007

I'm trying to automatically shade a number of cells dependant on the value in a single cell. ie. If D2="quote" then I want A2:Q2 to be yellow. If D2="Design" then I want A2:Q2 to be green etc etc. I have about 6 options in all of what D2 could be.
I then want to repeat this for about 200 rows.

View 7 Replies View Related

Colouring Cells Based On Date?

Feb 28, 2014

I am currently using a piece of code (within a bigger piece) that colours the dates in two columns based on how close it is to the current date. It works fine but sometimes the sheet it is looking in has over 3500 rows so it is taking for ever (well over 6 mins)

The code is

HTML Code:

Sub ColDate() 'date case opened
application.ScreenUpdating = False
Dim MyRg As Range
Dim F As Range
Dim DateDiff As Long
Set MyRg = Range("g1:h" & Range("H" & Rows.Count).End(xlUp).Row)
For Each F In MyRg

[code]...

View 1 Replies View Related

Auto Colouring Cells Containing Formulas

Jul 23, 2006

auto colouring cells containing formulas

View 2 Replies View Related

Colouring Cells To Show Academic Achievement

Apr 16, 2006

I'm a teacher and would like to show progress in my pupils achievements by colouring coding cells in excel. For each subject they are given a level, e.g. 2b. If they show progress, they would move up, i.e. to a 2a. The whole progress scale is shown below:

wc,wb,wa,1c,1b,1a,2c,2b,2a,3c,3b,3a,4c,4b,4a,5c,5b,5a,6c,6b,6a,7c,7b,7a

To make the spread sheet visual i would like colour code the cells depending on whether progress has or has not been made. If they go up (e.g. 2b to 2a) i would like the cell to turn green, if they go down (e.g. 2c to 1a) i would like the cell to turn red. If not progress has been made then the cell can stay uncoloured. Each cells colour would only be dependent on the cell directly to the left.

View 7 Replies View Related

Conditional Formatting - Colouring Percentage Of Multiple Cells Based On Date Range

Mar 12, 2014

I am trying to get a row of cells to highlight a percentage based on a date range

Below is an example of what my spreadsheet will look like, very simple for managers to read and understand but I am stuck on how i can get this to display the right way.

In the example i would need the Jan column to colour for a certain percent for 21 days and continue to feb for 26 days. Im not sure if this makes sense but this is what they are asking for. Colour bars to simple show the percent of days off each month.

Name Start Date End Date Jan Feb Mar

Dale 11/01/14 26/02/14 21 days 26 days

I have attached the spreadsheet for an example : Book1.xlsx‎

View 3 Replies View Related

Cell Colouring In

Aug 7, 2006

Is it possible to get the following to work.

If cell A2 has the number 5 in it (as a result of a calculation in that cell), is it possible to get the next five cells in that cell to colour themselves in?

Obviously, as and when the value in cell A2 changes, i need the number of cells coloured in to change as well.

In addition to this, the rows that this will happen in will vary week to week so i'm not sure if VBA is the way to do this.

Also would there be any problem with negative figures as when that happens i don't want any cells to colour in at all.

View 9 Replies View Related

Colouring Autoshapes Using Macro

Jan 27, 2009

Just trying to work out the best way to be able to determine autoshape colours using cell values. For example I have 12 shapes that need to coloured either Red, Green or Orange depending on a specific cells value, 1 for Red, 2 for Green and 3 for Orange.

I have sort of managed to successfully complete this for 1 of the shapes, by using the RGB Fill option (Using 3 = Red, 4 = Green and 45 = Orange). But cannot for the life of me work out how to do this for multiple shapes using different cell triggers. Below is the code that I currently have and the spreadsheet that is linked to:

View 5 Replies View Related

Reference Cell Colouring

Oct 18, 2011

How do i have colouring to a reference cell what i mean is that on certain formula i get BUY or Sell on that cell. As per the conditional formatting i have made the colour change BLUE FOR "BUY" & RED FOR "SELL"

On second sheet i link the above TEXT., but the COLOUR OF THE TEXT Does not come.

Does CONDITIONAL Formatting come with reference cell.

View 7 Replies View Related

Colouring The Row By Conditional Formatting

Aug 2, 2006

I have a gone through quite a few topics in this forum.....but couldnt find answer to my question....may be because its too basic. I have a worksheet with 10 columns. I am trying fill colour in the rows that have "text" in column J (in other words.....their column J is not blank). I figured out how to fill the colour in the cells in column J when they are empty, but cant figure out how to colour the entire row from A:J.

View 4 Replies View Related

Colouring Tabs Based On A Cell Value

Jul 28, 2009

I've been trying to get a macro together which would colour all the tabs in my workbook based on whether or not a certain value exists in a certain cell. In this case the cell is C7 and the word there is "elective class:".

View 7 Replies View Related

Colouring Cell If It Has A Specific Date

Feb 17, 2010

I have a column for each month where the dates are entered on rows. Is it possible I can color a cell if the date entered in a cell for that month is 15 days past the end of the month. Like, if in a January column I enter a date on one of the rows as Feb.20, then the cell fills with red colour. I tried doing it using conditional formatting, but don't know how to say 15 days past end of the month?

View 5 Replies View Related

Colouring Lines Of Text In Comments With VBA

Aug 2, 2008

I currently have some code which reads a stock file, adding up the stock for each individual item (which may be in one or more locations in the warehouse) and then placing the total stock count in a cell with the detail (of how much stock is in each location, the location and the expiry date) and a separate line for each location, in a comment.

The comment is constructed one line at a time as the code finds the stock records, see code below:


With shtWorking.Range(strStartColumn & intRow + 2)
oldComment = .Comment.Text
.Comment.Delete
.AddComment oldComment & vbNewLine & strComment
.Comment.Shape.TextFrame.AutoSize = True
End With
All this works very nicely, but I want to colour individual lines depending on the expiry date. This can be done manually in Excel, but I cannot find a way of colouring individual lines of text in a comment using VBA.

So, does anyone know of a way I can colour individual lines of text in a comment, using VBA?

View 9 Replies View Related

Colouring Cell Based On RGB And Index Numbers

Jan 28, 2014

As you can see from below I already have a spreadsheet which updates the fill colour of cells based on a certain criteria. This was initially set up in Excel 2003....I have now moved onto 2010 and want to use a certain colour based on it's RGB value. I tried as you can see from below, the part which is commented out (as it didn't work)

Code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim n As Long, lngIndex As Long
For n = 6 To 842

[Code].....

View 3 Replies View Related

Colouring Tabs Dependant On True / False Condition

Feb 21, 2010

I have "borrowed" the below code from a previous solved post, however am unsure how to adapt it.

View 7 Replies View Related

Linking Cells Globally To Allow Users Ability To Change Cells On Separate Sheet / Cells?

Feb 18, 2014

I have a workbook that uses the values that a user had entered into 3 cells to calculate multiple other charts/diagrams on multiple sheets within the workbook. Each sheet would show what the user had entered in the 3 cells to allow them to see what is being used to calculate each table. Is it possible to link these cells so that the user can change the 3 values without having to go back to where he originally entered the 3 values?

For example, a user has entered in 3 values in Sheet 1. A formula in Sheet 2 displays what is entered by the user and uses these calls in Sheet 2 for calculations. When the user wants to change the three values, he would have to navigate to Sheet 1 and enter in the new values to have the workbook recalculate all the tables. Is there a way to link the three cells from Sheet 1 and Sheet 2 so when the user is on Sheet 2, he has the opportunity to change the values on the current Sheet without having to navigate to Sheet 1 to do so?

View 1 Replies View Related

Copying Merged Cells (3 Cells) Based On Contents Of Any Of 3 Cells To Right

May 29, 2014

I wish to copy a merged cell (3 cells) based on if only 1 of 3 cells to the right contain "X". if the top cell does not contain "X" than the merged cell is not copied. Also, is therea more elegant to copy 3 columns at a time rather than do one at a time as my code shows:

Sub CopyICUCAPU()
'
' CopyICUCAPU Macro
'
Dim i As Integer

[Code].....

View 14 Replies View Related

Values In Each Cells(A) Represented Back At Cells(B) But No Repetition If Some Cells(A) Contains Same Value

Dec 9, 2008

I did my search, but cant find and knows what key search to look/type for...

If i have data A1 through A10, such as 1 1 2 2 2 2 3 3 3 3

How can i get column B1 through B3 as 1 2 3 ?

View 9 Replies View Related

Date Cells In Project Plan To Change Based On Other Cells Including Other Date Cells

Oct 31, 2008

This is a project plan with tasks and dates. Column A is the activity number. (Example 1, 2, 3" etc). Column B is the task (Ex. "Complete Report"). Column C is number of days required to complete the task. Column D is the dependency column. (Ex. Cell D2 =1 in other words Task 2 is dependent on task 1). Column E is the date.

I would like to have a seperate start date cell and a go live date cell.

The objective is to enter a start date, and have each column E date increase based on the number of days entered in Column C. If a task is dependent on another and I change the number of days in Column C I need the dependent task to change the same amount of days.

View 9 Replies View Related

How To Copy Row With Formula In Locked Cells And Insert Copied Cells In Protected Sheet

Mar 29, 2014

Have you ever copy a row with formula in locked cells & insert it in a protected worksheet?

View 1 Replies View Related

Lookup Range Of Cells And Populate Specific Cells Based On Matching Data?

May 23, 2014

I am trying to build a staff roster. The staff rotate over a 4 week cycle. the name of the staff member, and their shift needs to be looked up from the key then matched with the particular week. the name and shift then need to populate specific cells.

I have attached the worksheet so you can see what i am trying to achieve.

View 2 Replies View Related

Copy Filter Data And Paste It On Another Workbook With Special Cells (Only Visible Cells)

Apr 12, 2014

I am using code to filter my 4 sheets Greater then 0 (zero)

After apply above filter now i need to copy multiple rows and paste on another specific workbook for paste i m using below code:

for 1st sheet with the name ("V2")

for 2nd sheet with the name("LV")

For 3rd sheet with the name ("F2")

and 4th sheet with the name("L2")

If I play above code one by one all is going very well,,,,,,or if use in this way all is going very well

But here is a big problem..........if any sheet have no value greater then 0(zero)....then code paste all data... e.g shssts("LV") .Range("C5:C54").Copy but C5:C54 have no data greater then 0(zero) and it will paste on another sheet c5:c54 and again new sheets data will paste below the c54 while c5:c54 have no data.

So I want if any sheet have no data with range is greater then 0(Zero) then skip the copy paste code or use like SpecialCells(xlCellTypeVisible) .

View 5 Replies View Related

Protect Certain Locked Cells From Editing And Allow Certain Unlocked Cells To Be Changed On Multiple Worksheets?

Jan 31, 2014

1.I need to protect certain locked cells from editing and allow certain unlocked cells to be changed on multiple worksheets.

2.When all of the changes are made to the unlocked cells, I need to password protect the entire workbook (except one worksheet) from any changes. (i.e. Prevent even the unlocked cells from being edited)

3.I also need a password to un-protect the workbook and return it to the state described in # 1. above .

View 1 Replies View Related

Excel 2007 :: Conditional Formatting Empty Cells Based On Full Cells?

Nov 17, 2011

Working in Excel 2007. I am using excel for a data log (basically) and want it to format all empty cells in a row yellow if there is data in column A

Basically, If i have a value in A2, I want any empty cell between B2-G2 to be filled in yellow (as an idicator to the inputter that the cell needs to be completed).

there is already conditional formatting on these cells, which i want to maintain for the non-empty cells. I also have "0" as a value, so I couldn't use the basic conditional formatting setting it =0, it highlighted cells with $0.00, which i do not want.

View 5 Replies View Related

Excel 2003 :: Conditional Format Top / Mid / Bottom 33% Of Cells But Ignoring Blank Cells

Mar 25, 2012

I am trying to conditionally format the top middle and bottom thirds of a range of data. Problem is, that the range needs to be flexible as sometimes there may be a maximum of 36 cells with data, but sometimes there may be less (so there are blank cells in the range that need not be counted). The methods I have tried always include the blank cells, and so it is not equally formatting the thirds (as it includes the blanks cells as part of the bottom data)....

Here are the 2 methods Ive tried so far using excel 2003)
Top 34%:
=IF(INT(COUNT($D$3:$D$38)*34%)>0,LARGE($D$3:$D$38,INT(COUNT($D$3:$D
$38)*34%)),MAX( $D$3:$D$38))0,LARGE($D$3:$D$38,INT(COUNT($D$3:$D
$38)*67%)),MAX( $D$3:$D$38))0,LARGE($D$3:$D$38,INT(COUNT($D$3:$D
$38)*100%)),MAX( $D$3:$D$38))

View 4 Replies View Related

Excel 2010 :: Color Fill A Range Of Cells If Specific Cells Not Blank

Feb 7, 2013

I am using Excel 2010 and basically i am trying to fill a range of cell with a green color if any value was enter in a specific cells. Example: I would like to fill range: A10:c13 with a green color (regardless of the cells content in this range) if a value was entered in cell C10 or C11 or C12 or C13.

I've tried conditional formatting but unfortunately I'll have to apply formatting for every cell and for a range of over hundred cells is not efficient.

View 7 Replies View Related

Locking Text In Cells But Not The Ability To Change Colour Of Cells With Mouse Click

Mar 5, 2013

Locking text in cells but not the ability to change colour of cells

******** width="234" height="60" frameborder="0" marginwidth="0"
marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" id="aswift_0" name="aswift_0" style="left: 0px; position: absolute; top: 0px;">*********>

I have a spreadsheet where I can change the colour of a cell by clicking the mouse, I also have text in many of the cells.

What I need to do is protect (lock) the text so that no one can change the text in any of the cells, but I still want to be able to change the colour of the cells by clicking the mouse in that cell.

View 2 Replies View Related

Sort Rows To Show Values Of Cells In Sequence And Eliminate Empty Cells

Nov 11, 2013

I have data on 400 rows. Each row has a maximum of 10 cells with data, but many have empty cells with no data. I would like to sort each row to show values of cells in sequence and eliminate empty cells. I can use the sort row function but its a long process for 400 individual rows. Is there an easier way?

View 1 Replies View Related







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