Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default value of any cell in row 1 = 8 then colour the whole row

How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row light
yellow.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default value of any cell in row 1 = 8 then colour the whole row

Hi JJ,

If Evaluate("=COUNTIF(A1:IV1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If


"JJ" wrote in message
...
How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row light
yellow.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default value of any cell in row 1 = 8 then colour the whole row

Thanks William, that works beautifully.


"William Benson" wrote in message
...
Hi JJ,

If Evaluate("=COUNTIF(A1:IV1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If


"JJ" wrote in message
...
How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row light
yellow.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default value of any cell in row 1 = 8 then colour the whole row

Sure ... a bit shorter code and also easier to see how to use it in looping
by rows ...

If Evaluate("=COUNTIF(1:1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If
End Sub

"William Benson" wrote in message
...
Hi JJ,

If Evaluate("=COUNTIF(A1:IV1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If


"JJ" wrote in message
...
How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row light
yellow.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default value of any cell in row 1 = 8 then colour the whole row

Just so you don't stunt your learning growth, using evaluate would be the
slow way to call countif. It can be called directly from VBA

If Application.WorksheetFunction.COUNTIF(rows(1),8) 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If

--
Regards,
Tom Ogilvy


"JJ" wrote in message
...
Thanks William, that works beautifully.


"William Benson" wrote in message
...
Hi JJ,

If Evaluate("=COUNTIF(A1:IV1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If


"JJ" wrote in message
...
How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row light
yellow.









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default value of any cell in row 1 = 8 then colour the whole row

Tom -- you're right on top of things as always!!! In this case, I was not on
the left hand side of the learning curve, just lazy.


Not in defence of my laziness, but ...

1) why are not all WorksheetFunctions supported? .. a fact which often
discourages me from bothering with WorksheetFunction.

2) Is there a performance difference?

3) Are their losses from the WorksheetFunction collection (or whatever it
is) with new releases of Excel, or only new additions?

"Tom Ogilvy" wrote in message
...
Just so you don't stunt your learning growth, using evaluate would be the
slow way to call countif. It can be called directly from VBA

If Application.WorksheetFunction.COUNTIF(rows(1),8) 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If

--
Regards,
Tom Ogilvy


"JJ" wrote in message
...
Thanks William, that works beautifully.


"William Benson" wrote in message
...
Hi JJ,

If Evaluate("=COUNTIF(A1:IV1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If


"JJ" wrote in message
...
How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row light
yellow.









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default value of any cell in row 1 = 8 then colour the whole row

the general rule is that functions duplicated by VBA are not available in
the WorksheetFunctions collection.

According to Microsoft, evaluate or square brackets is slower. In most
cases I have found this to be true. It makes sense, because the entire
string has to be passed to Excel from VBA for evaluation. In other words,
Excel has to parse the string and determine that countif is the function
being called and interpret the string address into a range argument. Using
Worksheetfunction I would assume vba can call that function directly and
pass the reference to the range.

As far as I know, there are no losses from the worksheetfunction collection
(for example, round continues to exist even though VBA now has a round -
although the algorithms are different.) But certainly wouldn't be the
authority on this.

--
Regards,
Tom Ogilvy

"William Benson" wrote in message
...
Tom -- you're right on top of things as always!!! In this case, I was not

on
the left hand side of the learning curve, just lazy.


Not in defence of my laziness, but ...

1) why are not all WorksheetFunctions supported? .. a fact which often
discourages me from bothering with WorksheetFunction.

2) Is there a performance difference?

3) Are their losses from the WorksheetFunction collection (or whatever it
is) with new releases of Excel, or only new additions?

"Tom Ogilvy" wrote in message
...
Just so you don't stunt your learning growth, using evaluate would be

the
slow way to call countif. It can be called directly from VBA

If Application.WorksheetFunction.COUNTIF(rows(1),8) 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If

--
Regards,
Tom Ogilvy


"JJ" wrote in message
...
Thanks William, that works beautifully.


"William Benson" wrote in message
...
Hi JJ,

If Evaluate("=COUNTIF(A1:IV1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If


"JJ" wrote in message
...
How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row

light
yellow.











  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default value of any cell in row 1 = 8 then colour the whole row

Thanks Tom!!!!!!!!!! Really appreciate the depth you provide.
"Tom Ogilvy" wrote in message
...
the general rule is that functions duplicated by VBA are not available in
the WorksheetFunctions collection.

According to Microsoft, evaluate or square brackets is slower. In most
cases I have found this to be true. It makes sense, because the entire
string has to be passed to Excel from VBA for evaluation. In other words,
Excel has to parse the string and determine that countif is the function
being called and interpret the string address into a range argument.
Using
Worksheetfunction I would assume vba can call that function directly and
pass the reference to the range.

As far as I know, there are no losses from the worksheetfunction
collection
(for example, round continues to exist even though VBA now has a round -
although the algorithms are different.) But certainly wouldn't be the
authority on this.

--
Regards,
Tom Ogilvy

"William Benson" wrote in message
...
Tom -- you're right on top of things as always!!! In this case, I was not

on
the left hand side of the learning curve, just lazy.


Not in defence of my laziness, but ...

1) why are not all WorksheetFunctions supported? .. a fact which often
discourages me from bothering with WorksheetFunction.

2) Is there a performance difference?

3) Are their losses from the WorksheetFunction collection (or whatever it
is) with new releases of Excel, or only new additions?

"Tom Ogilvy" wrote in message
...
Just so you don't stunt your learning growth, using evaluate would be

the
slow way to call countif. It can be called directly from VBA

If Application.WorksheetFunction.COUNTIF(rows(1),8) 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If

--
Regards,
Tom Ogilvy


"JJ" wrote in message
...
Thanks William, that works beautifully.


"William Benson" wrote in message
...
Hi JJ,

If Evaluate("=COUNTIF(A1:IV1,8)") 0 Then
'Yellow
Cells(1).EntireRow.Interior.ColorIndex = 6
Else
'None
Cells(1).EntireRow.Interior.ColorIndex = -4142
End If


"JJ" wrote in message
...
How would I do this please?

If the value of any cell in row 1 = 8 then colour the whole row

light
yellow.













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
textBox font colour the same as cell font colour???????? Sophie Excel Discussion (Misc queries) 4 February 13th 09 10:15 AM
How can colour of cell shading be fixed to one colour Tabrez Excel Discussion (Misc queries) 2 September 23rd 08 04:55 PM
change a cell background colour to my own RGB colour requirements Stephen Doughty Excel Discussion (Misc queries) 4 June 16th 06 01:08 PM
How can i change cell colour depending on month of date in cell? andy75 Excel Discussion (Misc queries) 2 January 6th 06 07:46 AM
Conditional Format with VBA - Interior Colour of cell based on value from in-cell dropdown Steve[_52_] Excel Programming 5 June 15th 04 11:45 AM


All times are GMT +1. The time now is 03:54 AM.

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"