Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use colour by export to excel.

Status
Not open for further replies.

Elsje

Programmer
Feb 20, 2004
44
BE
Hey,

I have made an export to excel. And now I have the following problem. In my export I want to change the colour of a certain cell to red if a condition is true.
For example
column A ~ Column B ~ Column C ~ Column D
Situation1 ~ 10 ~ 5 ~ xxxxx
Situation2 ~ 0 ~ 5 ~ xxxxx
Situtaion3 ~ 15 ~ 20 ~ xxxxxx

I want the text in column D red if column C is bigger dan column B. So in situtation 2 and 3 it needs to be red.
Because I don't now the result of column C in my program (this is a formula) I need to be able to do this with a formula.
Is this possible?

Thanks in advance and greetings
Els
 


hi,

This can be done in Excel via Conditional Formatting, or you could say, for any row...
Code:
with xlsht.cells(ThisRow, "D")
  if .offset(0,-1).value > .offset(0,-2).value then
    .interior.color = vbred 
  end if
end with


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top