Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Highlighting the cell in Excel!
#1
Solved: 10 Years, 9 Months ago
Hi,
I need to check the value in the Cell of the excel sheet and have to highlight it with some color.
For example: If the cell has FALSE as the value, i need to highlight the text with Red color.

Can anyone please help me out.

thanks
Reply
#2
Solved: 10 Years, 9 Months ago
Hi Nagesh PV,

You can have an idea of changing cell interior/ font colors in excell sheet from the following code.

Code:
Set  xl=createobject ("excel.application")
set xls=xl.workbooks.add
For i=0 to 54
    xls.sheets(3).cells(i,1)=i
    xls.sheets(3).cells(i,1).interior.colorindex=i
      xls.sheets(3).cells(i,1).Font.colorindex=i+20
Next

xls.saveas""C:\Documents and Settings\rekha\Desktop\Colors.xls""
xls.quit
xl.quit
xls=nothing
xl=nothing



Try this and let us know how it worked for you.
Rekha
Reply
#3
Solved: 10 Years, 9 Months ago
Hi Rekha,

I could manage with the code..thanks a lot!
Reply
#4
Solved: 10 Years, 9 Months ago
I tried with the code below,
Code:
Public Function Highlight_Cell()
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set ObjWorkBook = objExcel.Workbooks.open (DataSheet_Path &"\" &  "DWU.xls")
   Set ObjWorkSheet = ObjWorkbook.WorkSheets("DS_Result")
    For Each Cell In ObjWorkSheet.UsedRange
    If Cell.Value = "False" Then
      Cell.Interior.ColorIndex = 3
     End If
  Next
ObjWorkBook.Save
ObjWorkBook.close
Set objExcel = nothing
End Function

It works fine for me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)