![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Highlighting cell based on condition Hi all, I have a script which will open a excel file and check whether the cell value in Column F3 to J3 are greater than 0, if yes then those cells will be highlighted with some color. The script works. But the problem is only the first row is getting highlighted and then the script stops. It is not looping through all the cells and checking for the value in the Range. Can anyone tell me where i am doing wrong. Below is the script. Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Open("C:\test.xls") Set objWorksheet = objWorkbook.Worksheets(1) Set objRange = objWorksheet.Range("F3:J3") For Each objCell in objRange Wscript.Echo objCell.Value If IsNumeric(objCell.Value) Then If objCell.Value > 0 Then objCell.Interior.ColorIndex = 10 End If End If Next Next Wscript.echo "Done" |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Highlighting cell based on condition "Codeblack" <Codeblack@xxxxxx> wrote in message news:B18C2ECF-9BC8-4D77-A5CC-4C0DA741B53D@xxxxxx Quote: > Hi all, > > I have a script which will open a excel file and check whether the cell > value in Column F3 to J3 are greater than 0, if yes then those cells will > be > highlighted with some color. The script works. But the problem is only the > first row is getting highlighted and then the script stops. It is not > looping > through all the cells and checking for the value in the Range. Can anyone > tell me where i am doing wrong. Below is the script. > > > > Set objExcel = CreateObject("Excel.Application") > objExcel.Visible = True > Set objWorkbook = objExcel.Workbooks.Open("C:\test.xls") > Set objWorksheet = objWorkbook.Worksheets(1) > > > Set objRange = objWorksheet.Range("F3:J3") > > For Each objCell in objRange > Wscript.Echo objCell.Value > > If IsNumeric(objCell.Value) Then > If objCell.Value > 0 Then > objCell.Interior.ColorIndex = 10 > End If > End If > Next > Next > Wscript.echo "Done" > F3:J5. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Highlighting cell based on condition Thank you. This worked. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| More than one condition with the if-Statement | PowerShell | |||
| Re: using xp based drive as slave on new vista based computer?? | Vista installation & setup | |||
| Condition Zero and NHL 2007 | Vista Games | |||
| IE 7 cannot run, DoS condition | Vista General | |||