I am working on some macros to automate some organization of data for parts
inventory management purposes, and reporting. I wanted to have certain rows
get highlighted automatically when the data is all imported and it meets
certain criteria. FOR INSTANCE:
If COLUMN D is greater than 3, bold the entire ROW with X coloring. What is
the most efficient method for this? Perhaps even step it out further and put
in ranges to bold different collors instead of just a blanket greater than
(ie: between 3 and 6 bold X color, between 7 and 10 bold X color, etc. )
Hi,
If you only need four colours, including the default one, conditional
formatting might fulfil your needs, without resorting to vba.
For more than four colours, a vba solution is fairly straightforward. For
example, putting the following code in the Worksheet will automatically
change the colours as the values in Column D change:
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Column = 4 Then
Select Case .Value
Case 0 To 2.99
.EntireRow.Interior.ColorIndex = 4
Case 3 To 5.99
.EntireRow.Interior.ColorIndex = 6
Case 6 To 9.99
.EntireRow.Interior.ColorIndex = 39
Case 10 To 14.99
.EntireRow.Interior.ColorIndex = 41
Case Is gt;= 15
.EntireRow.Interior.ColorIndex = 3
Case Else
.EntireRow.Interior.ColorIndex = 0
End Select
End If
End With
End Sub
Six csaes are catered for; add or delete as needed.
Cheersquot;bodhisatvaofboogiequot; gt; wrote in
message news
gt; I am working on some macros to automate some organization of data for
parts
gt; inventory management purposes, and reporting. I wanted to have certain
rows
gt; get highlighted automatically when the data is all imported and it meets
gt; certain criteria. FOR INSTANCE:
gt;
gt; If COLUMN D is greater than 3, bold the entire ROW with X coloring. What
is
gt; the most efficient method for this? Perhaps even step it out further and
put
gt; in ranges to bold different collors instead of just a blanket greater than
gt; (ie: between 3 and 6 bold X color, between 7 and 10 bold X color, etc. )
Thanks for that
quot;macropodquot; wrote:
gt; Hi,
gt;
gt; If you only need four colours, including the default one, conditional
gt; formatting might fulfil your needs, without resorting to vba.
gt;
gt; For more than four colours, a vba solution is fairly straightforward. For
gt; example, putting the following code in the Worksheet will automatically
gt; change the colours as the values in Column D change:
gt;
gt; Private Sub Worksheet_Change(ByVal Target As Range)
gt; With Target
gt; If .Column = 4 Then
gt; Select Case .Value
gt; Case 0 To 2.99
gt; .EntireRow.Interior.ColorIndex = 4
gt; Case 3 To 5.99
gt; .EntireRow.Interior.ColorIndex = 6
gt; Case 6 To 9.99
gt; .EntireRow.Interior.ColorIndex = 39
gt; Case 10 To 14.99
gt; .EntireRow.Interior.ColorIndex = 41
gt; Case Is gt;= 15
gt; .EntireRow.Interior.ColorIndex = 3
gt; Case Else
gt; .EntireRow.Interior.ColorIndex = 0
gt; End Select
gt; End If
gt; End With
gt; End Sub
gt;
gt; Six csaes are catered for; add or delete as needed.
gt;
gt; Cheers
gt;
gt;
gt; quot;bodhisatvaofboogiequot; gt; wrote in
gt; message news
gt; gt; I am working on some macros to automate some organization of data for
gt; parts
gt; gt; inventory management purposes, and reporting. I wanted to have certain
gt; rows
gt; gt; get highlighted automatically when the data is all imported and it meets
gt; gt; certain criteria. FOR INSTANCE:
gt; gt;
gt; gt; If COLUMN D is greater than 3, bold the entire ROW with X coloring. What
gt; is
gt; gt; the most efficient method for this? Perhaps even step it out further and
gt; put
gt; gt; in ranges to bold different collors instead of just a blanket greater than
gt; gt; (ie: between 3 and 6 bold X color, between 7 and 10 bold X color, etc. )
gt;
gt;
gt;
- May 16 Wed 2007 20:37
If Statements Question
close
全站熱搜
留言列表
發表留言