Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Mental Block! - Event Change Conditional Formatting

Please put me out my misery folkes.
I have a range of data of which I want to conditional format the
numbers in columns G to L inclusive (yes the columns also contain
text).
I want to do something along the lines of :-

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target = Columns("G:L")
If Target.Value < 1 Then
Selection.Font.ColorIndex = 3
End If
End Sub

I know this syntax is wrong but hopefully it shows you what I'm after.I
know I will have to add an IsNumber in there also, but my main question
is how you reference the Target to what you want it to be.

thanks folkes.
Donna

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Mental Block! - Event Change Conditional Formatting


try:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target = Columns("G:L")
If Target.Value < 1 Then
*Target*.Font.ColorIndex = 3
End If
End Sub


It would however be handier to use the Conditional Format tool. Select
Columns G:L and in the "Formula Is" appropriate box, type in =G1<1;
Choose format option to suit.


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=373448

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Mental Block! - Event Change Conditional Formatting

Hi,
try

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ExitSub
Application.EnableEvents = False
If Not Intersect(Target, Range("G:L")) Is Nothing Then
With Target
If Not IsEmpty(.Value) And IsNumeric(.Value) Then
If .Value < 1 Then
.Font.ColorIndex = 3
End If
End If
End With
End If
ExitSub:
Application.EnableEvents = True
End Sub


HTH

" wrote:

Please put me out my misery folkes.
I have a range of data of which I want to conditional format the
numbers in columns G to L inclusive (yes the columns also contain
text).
I want to do something along the lines of :-

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target = Columns("G:L")
If Target.Value < 1 Then
Selection.Font.ColorIndex = 3
End If
End Sub

I know this syntax is wrong but hopefully it shows you what I'm after.I
know I will have to add an IsNumber in there also, but my main question
is how you reference the Target to what you want it to be.

thanks folkes.
Donna


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Mental Block! - Event Change Conditional Formatting

Thanks for your repluys Chaps.
David, I can't use the conditional Format tool (I don't think) as I
have in effect 2 contitional formats to apply to each cell, but as far
as I can gather one always has priority over the other so both can not
be applied at the same time.

I got my selectionchange event to work but found it quite slow in
updating the cells every time you selected a cell let alone changing it
so I have set it to run with a button as essentially it only needs
updating when more data is imported into the file.

Thanks again for your time.
Donna

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 formatting does not change when values change. ?? Texana Excel Worksheet Functions 4 August 20th 07 12:20 AM
mental block Lost in excel Excel Worksheet Functions 3 January 14th 07 08:18 PM
Mental block Jack Sheet New Users to Excel 3 March 22nd 06 08:31 PM
block event Roman Töngi Excel Programming 1 January 11th 05 11:16 AM
Event for conditional formatting? Tommi[_2_] Excel Programming 2 October 8th 03 09:05 AM


All times are GMT +1. The time now is 08:27 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"