VBA Help:Change Color of Cells

Dear All,

How to change the color of cells?
I'm confused whether to use range object or cells object.
Pls give me example.

Thanks

Robert Lie
0
1/25/2006 2:18:03 AM
excel 39879 articles. 2 followers. Follow

3 Replies
548 Views

Similar Articles

[PageSpeed] 54

Hi Robert,

The Cells property returns a range object, so you could, for example, use 
either of the following equivalent instructions:


        Range("A1:A10").Interior.ColorIndex = 6

        Cells(1, 1).Resize(10).Interior.ColorIndex = 6


---
Regards,
Norman


"Robert Lie" <robert.lie24@gmail.com> wrote in message 
news:%23vv10TVIGHA.2928@TK2MSFTNGP10.phx.gbl...
> Dear All,
>
> How to change the color of cells?
> I'm confused whether to use range object or cells object.
> Pls give me example.
>
> Thanks
>
> Robert Lie 


0
normanjones (1047)
1/25/2006 2:24:38 AM
Hi All,

I need give a specific color for the cells.
Do you could give me the list of colorindex, since I couldn't find the 
list from VBA Help?

Thanks

Robert Lie


Norman Jones wrote:
> Hi Robert,
> 
> The Cells property returns a range object, so you could, for example, use 
> either of the following equivalent instructions:
> 
> 
>         Range("A1:A10").Interior.ColorIndex = 6
> 
>         Cells(1, 1).Resize(10).Interior.ColorIndex = 6
> 
> 
> ---
> Regards,
> Norman
> 
> 
> "Robert Lie" <robert.lie24@gmail.com> wrote in message 
> news:%23vv10TVIGHA.2928@TK2MSFTNGP10.phx.gbl...
> 
>>Dear All,
>>
>>How to change the color of cells?
>>I'm confused whether to use range object or cells object.
>>Pls give me example.
>>
>>Thanks
>>
>>Robert Lie 
> 
> 
> 
0
1/25/2006 2:56:44 AM
Hi Robert,

With a blank worksheet active try:

'===============>>
Sub ColourTable()
    Dim iCtr As Long

    For iCtr = 1 To 56
        Cells(iCtr, 1).Interior.ColorIndex = iCtr
        Cells(iCtr, 2).Value = "'" & Right("000000" & _
                            Hex(ThisWorkbook.Colors(iCtr)), 6)
        Cells(iCtr, 3).Value = iCtr
        Cells(iCtr, 4).Value = Cells(iCtr, 1).Interior.Color
        Cells(iCtr, 2).Font.Name = "Courier New"
        Cells(iCtr, 2).HorizontalAlignment = xlRight
        Cells(iCtr, 3).HorizontalAlignment = xlCenter
        Cells(iCtr, 4).HorizontalAlignment = xlLeft
    Next iCtr

End Sub
'<<===============

See also David McRitchie's Color page at:

        http://www.mvps.org/dmcritchie/excel/colors.htm


---
Regards,
Norman



"Robert Lie" <robert.lie24@gmail.com> wrote in message 
news:OljXdpVIGHA.1312@TK2MSFTNGP09.phx.gbl...
> Hi All,
>
> I need give a specific color for the cells.
> Do you could give me the list of colorindex, since I couldn't find the 
> list from VBA Help?
>
> Thanks
>
> Robert Lie
>
>
> Norman Jones wrote:
>> Hi Robert,
>>
>> The Cells property returns a range object, so you could, for example, use 
>> either of the following equivalent instructions:
>>
>>
>>         Range("A1:A10").Interior.ColorIndex = 6
>>
>>         Cells(1, 1).Resize(10).Interior.ColorIndex = 6
>>
>>
>> ---
>> Regards,
>> Norman
>>
>>
>> "Robert Lie" <robert.lie24@gmail.com> wrote in message 
>> news:%23vv10TVIGHA.2928@TK2MSFTNGP10.phx.gbl...
>>
>>>Dear All,
>>>
>>>How to change the color of cells?
>>>I'm confused whether to use range object or cells object.
>>>Pls give me example.
>>>
>>>Thanks
>>>
>>>Robert Lie
>>
>> 

0
normanjones (1047)
1/25/2006 3:03:37 AM
Reply:

Similar Artilces:

how do i change tick marks of excel graph from vb.net
I'm trying to change using VB.NET the tick marks from their default outside position and place them inside the graph. How can this be done? ...

Hyperlink via indirect cell reference
Hi I have workbook that contains a number of sheets. On a separate sheet I would like to be able to insert a hyperlink so that I can jump to a specific sheet. However, rather than inserting all of the hyperlinks manually (I will have to replicate this over many workbooks) I wondered if there was a formula to allow me to jump to a cell (say A1) in another worksheet, based on the name of that worksheet being entered in a cell reference. For example - a number of worksheets called "Sheet1", "Sheet2", "Sheet3", "Sheet4". In another sh...

Excel, how do I change the column headings from letters to number
I have a spreadsheet that has numbered columns as opposed to the standard letters. How can I change this back to letters? Go to the Tools menu, choose Options, then the General tab. There, uncheck the R1C1 reference style setting. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "lazybee" <lazybee@discussions.microsoft.com> wrote in message news:030962A3-A111-4780-93C0-1D28003F1F20@microsoft.com... >I have a spreadsheet that has numbered columns as opposed to the >standard > letters. How can I change this ...

Exchange 2000 DST Changes
How is one supposed to address the DST changes for Exchange 2000 if they do not have extended support to get the patch? Will Microsoft be providing a workaround like they did for Windows 2000? I'm referencing the following article: http://support.microsoft.com/kb/930879 It states : What to do before you run the Exchange tool Install DST updates Before you run the Exchange tool, make sure that client and server computers are updated correctly with the operating system and application DST updates. These updates must be installed in the following order: 1. Install the Windows DST upda...

Help with a formula..
I am trying to create a formula that will take information from a cell on one sheet and combine it with text on another sheet. I know how to get the two together. My problem is that I want the part that is brought in to be bolded type. Here is what I have in the formula. ="we are pleased to submit our quotation for "&(cell reference)&" according to the following specifications." What I want to do is have the cell reference part be bold type. Is there a way to do that? It doesnt work if I bold the cell.. already tried it.. Any suggestions? Thanks! KK You'...

How do I freeze or lock cells to show up on each page without typ.
I have a 4 page sheet. I have a header already. But I want to freeze the cells that head up the first page. I've done it before in school but can't remember what it is called or how to do it...that's why I'm doing this. Anyway, I want these cells to print off on each new page without having to type them on each page. I hope that makes sense and I hope that someone can help me! If you mean for printing do file>page setup>sheet and select rows to repeat at top otherwise for viewing you can select a2 if the headers start in row 1 and do window> freeze panes ...

Help needed urgently
Hi, Im trying to check that one row of data satifies a criteria, then if it does it counts an entry in another column adjescent to it. Example: - Column A - Column B Blay - Y Blay - N Blay - Y Chop - N Chop - N High - Y What i would be asking (of a much bigger table) is If Column A = Blaydon and then column B (same row) = Y, then count. In this example I would want 2 returned as the answer. Is this possible? Thanks -- Andy Try one of these... Use cells to hold the criteria: D2 = Blaydon E2 = Y If you're using Excel 2007 or later: =COUNTIFS(A2:A7,...

RSS stack error help pls
I need to demo RSS for CRM (VPC image), i install the CRMrss from michaeljon miller site, extract to C:\Program Files\Microsoft CRM Server\CRMWeb\rss\ change the two .cs files so port include 5555. check the web.config to ensure app key is there for ISV integration. copy the isv.config.xml to the resources folder. go to visual studio 2005 command prompt, go to rss\code to run the make.bat. output from screen is 1 file copied. open the browser, i got the Exception of type System.Web.HttpException was thrown, stack error.. any help? thanks! ...

Rename Cell
How can I rename column A to read "bills" instead of the letter A? You can't. The closest you will get is to hide column headings, via Excel Option, and then create your own. -- Regards Dave Hawley www.ozgrid.com "shoe" <shoe@discussions.microsoft.com> wrote in message news:DBA970DF-D928-41EE-9565-4639E7D49BCE@microsoft.com... > How can I rename column A to read "bills" instead of the letter A? you cant change the headers or row labels but you can define you data as a list (or table) and the headings can then be used to refer...

merging 2 cells without losing data?
How can I merge 2 cells without losing data from the other cell? Hi Bob Not possible I'm afraid. Try placing the dat from both cells into one and use "Center across selection" under Format>Cells>Alignment Merge cells always end up causing grief. they are best avoided. ***** Posted via: http://www.ozgrid.com Excel Templates, Training & Add-ins. Free Excel Forum http://www.ozgrid.com/forum ***** "bob" <bobree@hotmail.com> wrote in message news:%23JuOM9HGEHA.2308@tk2msftngp13.phx.gbl... > How can I merge 2 cells without losing data from the other...

Changing Item #'s
Is it possible to change the item #'s after the item has already been entered? TMM: No there isn't in the "base" product, but MBS does have a tool that you can use called Item Modifier - this will allow you to change an Item number from one value to another. You can email this address below and they can answer any questions you have about the tool and can tell you what the cost of it is. mbsprofessionalservices@microsoft.com Hope that helps you out, JG "TMM" wrote: > Is it possible to change the item #'s after the item has already been entered? ...

Create static text from cell reference
Hey everyone... I have two columns of text which I'm combining in a third column using the formula (for C1, for example) =A1 & char(10) & B1 This gives me the contents of A1 on a line above the contents of B1 and works fine. What I NEED to do is somehow create column C as TEXT, not as a REFERENCED data from columns A and B. How do I create a cell that contains the actual TEXT content of another cell instead of a REFERENCE to the other cell? TIA... Select all the cells in "C" that have content. R-click them and select "Copy" then r-click again, sele...

help with dynamic tables
This is a bit complicated to explain but I'll try my best. In columns A, B, C I have different drop down lists. Column A has Store1, Store2, Store3, etc. Column B has Dept1, Dept2, Dep3, etc. Column C has ProductA, ProductB, ProductC. As of right now, these lists are not dependent on each other, I can choose anything from any list regardless of the previous category. Also, the length of these lists is undefined, meaning I will constantly be adding to them in sequential rows below. And then columns D and beyond have data such as Sales, Profits, # of items, etc. What I...

Cell Format #4
Is there a way to have a cell format based on contents of an i statement... Example if(C1="Input",and(C3,Format $#.##),if(C1="% of Revenue",and(C5,Forma #.##%),na) I want the If statement to test a condition, return contents of th correct cell and format automatically. Any help is appreciated -- bforster ----------------------------------------------------------------------- bforster1's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1177 View this thread: http://www.excelforum.com/showthread.php?threadid=26133 You can't change the fo...

Getting contents of adjacent cells
I want to divide the y1-axis column and save it to radius (y1/2) column. How do I do that? x-axis y1-axis radius(y1/2) 0 0.00 8.0000 1 0.25 8.0242 2 0.50 8.0691 3 0.75 8.1281 4 1.00 8.1989 5 1.25 8.2803 6 1.50 8.3716 7 1.75 8.4729 8 2.00 8.5832 hi divide the y1-axis by what? 2 as an guess with y1-axis in column c in the y1/2 column(d?), enter =C2/2 copy down. regards FSt1 "Rocky" wrote: > I want to divide the y1-axis column and save it to radius (y1/2) column. How > do I do that? > > x-axis y1-axis radius(y1/2) > 0 ...

Outlook color scheme
I've seen several different installs of Outlook 2003. Some have an orange interface, some blue, some grey. I'm not talking about Outlook web acess, but the local installed copy. Can anyone explain this? I would like to figure out how to change the interface color scheme. -Brian It uses Windows color schemes. Change those from Display Properties (Control Panel or right click you desktop). --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will ...

VLookup in VBA giving error message
Hi, I'm having trouble making the vlookup function work in VBA. the values that are used are all dates, I don't know if that makes a difference. Worksheets("sheet1").range("a1").value = application.WorksheetFunction. _ Vlookup(Range("c1"), range("a:a"), 2) this gives me a run-time error '1004' Unable to get the vlookup property of the Worksheet function class so i tried this: Worksheets("sheet1").range("a1").value = application.Vlookup(Range("c1"), _ range("a:a"), 2) but this gives me a #REF ...

Adding an item to a popup menu in outlook's inbox using VBA
Hello all, On rightclicking on the mailitems in the outlook's inbox we can see a popup menu.i want to add a menu item to that popup menu using outlook VBA. Please do help me in this regard. Thanking you regards, Revathy.v ...

converting tabular structures in a Word document into an actual table or reading data from the tabular structures using VBA code
I have a macro which can read the last cell/column of all tables in a Word 2003/2007 document and store the data in an MS-Access table. But, some Word documents have the data in structures like a table format but are not actually tables. The structure looks like a table, but the table borders are actually line connectors. These documents were created by a software(VeryPDF PDF to Word converter) which converted the PDF documents(the original format these documents were) into Word documents. 1. Is there a way I can convert/replace the tabular structures with actual tables in Word so t...

Help! Problem Referencing Excel 2003 in VB.NET
I am using Visual Studio 2008 Express Edition to develop some VB.NET code that manipulates Excel files. I am developing on a Vista/Excel 2007 machine, but I need the code to work on an XP/2003 machine as well. I initially set a reference to the Microsoft Excel 12.0 Object Library and imported the Microsoft.Office.Interop.Excel namespace. This works great on the VIsta/Excel 2007 machine, but it does not work on 2003, which needs the 11.0 library. I get an error that says "Unhandled Exception . . . Could not file or assembly 'Microsoft.Office.Interop.Excel, Version 12.0.0....

copying formulas in vba
Hey guys. I was wondering if someone could help me. I am writing a vba script that takes in data, analyzes it, and then copies the results to a new file. I am having a problem with two things. 1) I am using a template for the new file so there are a lot of formulas (sums and std) already defined and ready to use. However, there are some instances where there is a random amount of additional data I have to put in. So, I have to apply the same formulas to this new data. How do I copy formulas from one cell to another (allowing for a change in row) in vba? Lets say cell(1,4) has the form...

cell selection gone crazy on Excel 2003
All of a sudden the mouse is acting like it is held down, and will not stop selecting cells. Have tried double clicking, playing with the Function keys, all sorts of things, but to no avail... don't want to force quit. Any clues? TIA, Geri Hi Geri, See David McRitchie's notes at: http://www.mvps.org/dmcritchie/excel/ghosting.txt --- Regards, Norman "Tweedie-Vaughan" <Tweedie-Vaughan@discussions.microsoft.com> wrote in message news:438C3854-C74C-410A-BD88-DAA146172E99@microsoft.com... > All of a sudden the mouse is acting like it is held down, a...

Need Help with drop down list with conditions...
I need help. I'm having a very difficult time creating a sequence of list which change based on the item selected on the main list, lets call it the index: The Index list, the first list, would define vendors. In this case Hotel Companies (e.g Hilton, Marriott, Sheraton). The following list, the 2nd list, would define properties, but the properties would vary based on which hotel company is selected (e.g. If Hilton, then "The Plaza, the Waldorf Astoria. If Marriott, then Marriott Marquis, Marriott Convention Center etc etc...) on list #1. And Last but not least, the 3rd list would...

Average of logic cells
I used a logic test to determine some levels from raw scores. For EG >120 =5, 119-110 = 4, etc. I now want to dtermine an average score of several of the the results from the logic tests but it doesnt seem to work. (AVG does not recognise cells with logic tests) Can anyone help, please? -- ckdkvk ------------------------------------------------------------------------ ckdkvk's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29245 View this thread: http://www.excelforum.com/showthread.php?threadid=489704 hi, ckdkvk ! > I used a logic test to determine so...

Formatting Linked Cells
I have a project to do. I have to create an input worksheet that is the originator of other worksheets that are linked to the input worksheet. Is there a way to have the linked cells shown as a blank cell if the data (especially text data) is not enter in the input worksheet yet. MT Hi =IF(YourLink="","",YourLink) -- Arvi Laanemets (Don't use my reply address - it's spam-trap) "MT" <MT@discussions.microsoft.com> wrote in message news:5398D6F8-1554-46BB-B009-CCE3183C80ED@microsoft.com... > I have a project to do. I have to create an input ...