Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default VBA format of cells with colour based on IF formula


I have an IF formula that provides a €œY€ value if a cell date matches a
vlookup table of statuory holidays which works fine.

wsPh.Range("F7:AD7").Formula =
"=IF(ISNA(VLOOKUP(F5,StatHolidays,2,FALSE)),""""," "Y"")"

Based on that date I want to use code that will colour cells in a column.
Right now the shading does not work even though the €œY€ exists on the screen.
I also copied the value from H7 and paste special it back into H7 and it
still didnt work.

If h7 = "Y" Then
wsPh.Range("h9:h60").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Else
End If

P.S. is there any way to combine the €œWith€ criteria onto one (1) line
instead of three (3)

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default VBA format of cells with colour based on IF formula

It is okay I figured out my problem.

If wsPh.Range("h7") = "Y" Then

instead of


If h7 = "Y" Then


"Tony" wrote:


I have an IF formula that provides a €œY€ value if a cell date matches a
vlookup table of statuory holidays which works fine.

wsPh.Range("F7:AD7").Formula =
"=IF(ISNA(VLOOKUP(F5,StatHolidays,2,FALSE)),""""," "Y"")"

Based on that date I want to use code that will colour cells in a column.
Right now the shading does not work even though the €œY€ exists on the screen.
I also copied the value from H7 and paste special it back into H7 and it
still didnt work.

If h7 = "Y" Then
wsPh.Range("h9:h60").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Else
End If

P.S. is there any way to combine the €œWith€ criteria onto one (1) line
instead of three (3)

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default VBA format of cells with colour based on IF formula

What is h7 in your code (line If h7 = "Y" Then)?
You should use
If wsph.Range("h7") = "Y" Then
assuming wsph refers to the worksheet you want to color

No, you can not combine the rows since you are setting two differenct
properties.

"Tony" wrote:


I have an IF formula that provides a €œY€ value if a cell date matches a
vlookup table of statuory holidays which works fine.

wsPh.Range("F7:AD7").Formula =
"=IF(ISNA(VLOOKUP(F5,StatHolidays,2,FALSE)),""""," "Y"")"

Based on that date I want to use code that will colour cells in a column.
Right now the shading does not work even though the €œY€ exists on the screen.
I also copied the value from H7 and paste special it back into H7 and it
still didnt work.

If h7 = "Y" Then
wsPh.Range("h9:h60").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Else
End If

P.S. is there any way to combine the €œWith€ criteria onto one (1) line
instead of three (3)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Format based on existing cell colour ? Rich[_6_] Excel Discussion (Misc queries) 0 July 5th 08 08:15 AM
Is there a way to add cells based on their shading / fill colour? ChefAtSea Excel Discussion (Misc queries) 2 July 4th 07 01:22 PM
How can I colour format all cells based on their values magic Excel Worksheet Functions 3 April 19th 07 06:41 PM
How do I set a colour to 4 cells based on the value of a cell Andy64 Excel Discussion (Misc queries) 1 September 6th 05 06:46 PM
Adding colour to a range of cells based on one of the cells v... McKenna Excel Discussion (Misc queries) 4 March 11th 05 02:25 PM


All times are GMT +1. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"