Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to change interior color in excel, across multiple columns using a row variable?

user-image
Question ajoutée par Imran Ahmed , Manager-Planning & Delay Analyst , Nesma United Industries (NUI) Saudi Arabia
Date de publication: 2016/08/16
Utilisateur supprimé
par Utilisateur supprimé

Changing background colors in Excel VBA is easy. Use the Interior property to return an Interior object. Then use the ColorIndex property of the Interior object to set the background color of a cell.

Place three command buttons on your worksheet and add the following code lines:

1. The code line below sets the background color of cell A1 to light blue.

Fatimh Ali
par Fatimh Ali , accounting , Ali Alkalifah

you can use the conditional formatting in Home ribbon and their multiple choices or you can do your own by chose New rule  

Tomasz L
par Tomasz L , Reporting Specialist , Outworking

You could also use VBA (ColorIndex with variable row number).

 

Abdrabou Sharafeldin
par Abdrabou Sharafeldin , Education Consultant , Educational Services

Use Conditional Formatting in Home ribbon.

Hussein Elkhouly
par Hussein Elkhouly , Sales Executive / Manager , VARIETY CRUISES

the way your for loop works is that it is changing every cell. It can be optimized to color the row up to the last column at once.

Shady Ali - CMA
par Shady Ali - CMA , Senior Accountant , Smart Code for business services

through conditional formatting . 

Wasi Mohammad
par Wasi Mohammad , RF Drive Test Professional , Swedtel Arabia LTD

Conditional Formatting option under Home Menu offers Highlight Color Rule.

Ala'a Shalabiyeh
par Ala'a Shalabiyeh , Information Management Officer , Danish Refugee Council

I'm trying to highlight a row that's assigned to "RowNum" I want to highlight Columns A through O. I've tried the things below, But receive syntax errors on each.

sh1.Cells(RowNum,15).Interior.Color = RGB(127,187,199) sh1.Range("A"& RowNum :"O"& RowNum).interior.color = rgb (127,187,199)

In the past, I've used this to highlight a set range or individual cells.

sh1.Range("W1:X1").Interior.Color = RGB(252,213,180)

Bassam Ali Mohammed Al-mamari
par Bassam Ali Mohammed Al-mamari , مساعد الرصد والتقييم , برودحي سيستمز

sh1.Range("A" & RowNum & ":" & "O" & RowNum)

Utilisateur supprimé
par Utilisateur supprimé

I find creating a new rule easy from conditional formatting in the Home Pane. You can select a cell, give it values, names etc. Next to it formulate it by identifying ones you want to colour by saying =isodd or =iseven. Then highlight and go to conditional formatting -> New rule and choose your colour. It will indicate which (True or False) Need to be coloured. Try it. 

using VBA or through conditional formatting

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?