ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل Imran Ahmed , Manager-Planning & Delay Analyst , Nesma United Industries (NUI) Saudi Arabia
تاريخ النشر: 2016/08/16

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
من قبل 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
من قبل Tomasz L , Reporting Specialist , Outworking

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

 

Abdrabou Sharafeldin
من قبل Abdrabou Sharafeldin , Education Consultant , Educational Services

Use Conditional Formatting in Home ribbon.

Hussein Elkhouly
من قبل 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
من قبل Shady Ali - CMA , Senior Accountant , Smart Code for business services

through conditional formatting . 

Wasi Mohammad
من قبل Wasi Mohammad , RF Drive Test Professional , Swedtel Arabia LTD

Conditional Formatting option under Home Menu offers Highlight Color Rule.

Ala'a Shalabiyeh
من قبل Ala'a Shalabiyeh , Performance Information Management Assistant , Mercy Corps

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
من قبل Bassam Ali Mohammed Al-mamari , مساعد الرصد والتقييم , برودحي سيستمز

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

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. 

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟