VBA change row color

Nico0044 Posted messages 5 Status Member -  
 mt -
Hello,
I would like to create a small program in VBA but I am a beginner.
This program should run automatically when Excel starts.
Excel contains a table with 3 columns and an unknown number of rows (it grows as new data is added).
It should check the entire table, and as soon as there is a value of = 0 in a cell in column C, the entire row should turn red.
Thank you very much in advance for your help
Configuration: Windows XP Internet Explorer 6.0

2 answers

Polux31 Posted messages 7219 Status Member 1 204
 
Hello,

Open the VB editor (Alt+F11), add a module (Insert-> Module), then paste the code below:
Sub controleLigne() Dim ws As Worksheet Dim i As Long Set ws = Worksheets("Feuil1") 'name of the sheet where the check should be done With ws i = 1 'Number of the first row to test While .Range("C" & i).Value <> "" If .Range("C" & i).Value = 0 Then .Rows(i).Interior.Color = RGB(255, 0, 0) End If i = i + 1 Wend End With End Sub


Double-click on ThisWorkbook and paste the code below:
Private Sub Workbook_Open() Module1.controleLigne End Sub


Save your file, close it and reopen it...

;o)

polux
11
helly
 
very good
0
tod > helly
 
very well then
0
mt > helly
 
yes, very good what???
0
tod
 
interesting...thank you
0
mt
 
interesting and informative
2