Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default find a value in a column, if it matched, highlight that column

Hi,
how can I write a macro to do look for a value in a column, say column "C",
if it's greater than or equal to 250,000 then highlight that row (in any
colour), if it's less than or equal to 250,000, then also hightlight that row
(in any color). It will keep on finding value until the end of the row (when
there is a blank line).

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default find a value in a column, if it matched, highlight that column

Try conditional formatting.

Select all target rows, starting in row 1
Menu FormatConditional Formatting

Change Condition 1 to Formula is
Add a formulae of =$C125000
Select Patterns tab and choose a colour
OK
Click Add
Change Condition 1 to Formula is
Add a formulae of =$C1<=25000
Select Patterns tab and choose another colour
OK
OK



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Don Doan" wrote in message
...
Hi,
how can I write a macro to do look for a value in a column, say column
"C",
if it's greater than or equal to 250,000 then highlight that row (in any
colour), if it's less than or equal to 250,000, then also hightlight that
row
(in any color). It will keep on finding value until the end of the row
(when
there is a blank line).

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default find a value in a column, if it matched, highlight that column

Hi,
I understand that conditional formatting can be used to do just that.
However, conditional formatting only allow different 3 conditions.
I guess the reason i'm asking for help with macro because through Excel
codes, I can add more conditions later on if I ever needed it.


"Bob Phillips" wrote:

Try conditional formatting.

Select all target rows, starting in row 1
Menu FormatConditional Formatting

Change Condition 1 to Formula is
Add a formulae of =$C125000
Select Patterns tab and choose a colour
OK
Click Add
Change Condition 1 to Formula is
Add a formulae of =$C1<=25000
Select Patterns tab and choose another colour
OK
OK



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Don Doan" wrote in message
...
Hi,
how can I write a macro to do look for a value in a column, say column
"C",
if it's greater than or equal to 250,000 then highlight that row (in any
colour), if it's less than or equal to 250,000, then also hightlight that
row
(in any color). It will keep on finding value until the end of the row
(when
there is a blank line).

Thanks.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default find a value in a column, if it matched, highlight that column


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "C:C" '<=== change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 3000: .Entirerow.Interior.ColorIndex = 3 'red
Case 2500: .Entirerow.Interior.ColorIndex = 6 'yellow
Case 1500: .Entirerow.Interior.ColorIndex = 5 'blue
Case 1000: .Entirerow.Interior.ColorIndex = 10 'green
'etc.
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Don Doan" wrote in message
...
Hi,
I understand that conditional formatting can be used to do just that.
However, conditional formatting only allow different 3 conditions.
I guess the reason i'm asking for help with macro because through Excel
codes, I can add more conditions later on if I ever needed it.


"Bob Phillips" wrote:

Try conditional formatting.

Select all target rows, starting in row 1
Menu FormatConditional Formatting

Change Condition 1 to Formula is
Add a formulae of =$C125000
Select Patterns tab and choose a colour
OK
Click Add
Change Condition 1 to Formula is
Add a formulae of =$C1<=25000
Select Patterns tab and choose another colour
OK
OK



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Don Doan" wrote in message
...
Hi,
how can I write a macro to do look for a value in a column, say column
"C",
if it's greater than or equal to 250,000 then highlight that row (in
any
colour), if it's less than or equal to 250,000, then also hightlight
that
row
(in any color). It will keep on finding value until the end of the row
(when
there is a blank line).

Thanks.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default find a value in a column, if it matched, highlight that column

Oh, thank you so much for the details..I will test it out.
On the side, I really like to start learning how to write program in Excel,
where would be a good start??

"Bob Phillips" wrote:


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "C:C" '<=== change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 3000: .Entirerow.Interior.ColorIndex = 3 'red
Case 2500: .Entirerow.Interior.ColorIndex = 6 'yellow
Case 1500: .Entirerow.Interior.ColorIndex = 5 'blue
Case 1000: .Entirerow.Interior.ColorIndex = 10 'green
'etc.
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Don Doan" wrote in message
...
Hi,
I understand that conditional formatting can be used to do just that.
However, conditional formatting only allow different 3 conditions.
I guess the reason i'm asking for help with macro because through Excel
codes, I can add more conditions later on if I ever needed it.


"Bob Phillips" wrote:

Try conditional formatting.

Select all target rows, starting in row 1
Menu FormatConditional Formatting

Change Condition 1 to Formula is
Add a formulae of =$C125000
Select Patterns tab and choose a colour
OK
Click Add
Change Condition 1 to Formula is
Add a formulae of =$C1<=25000
Select Patterns tab and choose another colour
OK
OK



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Don Doan" wrote in message
...
Hi,
how can I write a macro to do look for a value in a column, say column
"C",
if it's greater than or equal to 250,000 then highlight that row (in
any
colour), if it's less than or equal to 250,000, then also hightlight
that
row
(in any color). It will keep on finding value until the end of the row
(when
there is a blank line).

Thanks.








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
how to match matched ID and name columns to organized ID column Jolanta[_2_] Excel Discussion (Misc queries) 1 March 9th 09 09:35 PM
Most frequent string in a column matched against a value in its ro Babymech Excel Discussion (Misc queries) 1 June 13th 08 04:44 PM
Search Specific Column for a matched entry Carlee Excel Programming 3 June 10th 07 05:23 PM
How can i have all alike product codes in column A be matched with like cities in column B and then add the totals that are in column C [email protected] Excel Programming 4 August 2nd 06 01:10 AM
Return Title to matched column [email protected] New Users to Excel 1 February 21st 06 06:04 AM


All times are GMT +1. The time now is 10:39 AM.

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

About Us

"It's about Microsoft Excel"