Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Identify rows with certain background color?

Hi,

Is there a way (programmatically) to identify rows with certain
background color say, "red"?

Thank you.

Don Li
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Identify rows with certain background color?

Don,

You can certainly identify the cell's background color with code
like

If Range("A1").Interior.ColorIndex = 3 Then
' do something
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"DonLi" wrote in message
om...
Hi,

Is there a way (programmatically) to identify rows with certain
background color say, "red"?

Thank you.

Don Li



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Identify rows with certain background color?

Don Li,

Sub test()
Dim rng As Range, rngRed As Range

For Each rng In Sheet1.UsedRange.Rows.EntireRow
If rng.Interior.Color = vbRed Then
If rngRed Is Nothing Then
Set rngRed = rng
Else
Set rngRed = Union(rngRed, rng)
End If
End If
Next

If Not rngRed Is Nothing Then rngRed.Select
End Sub


Rob

"DonLi" wrote in message
om...
Hi,

Is there a way (programmatically) to identify rows with certain
background color say, "red"?

Thank you.

Don Li



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Identify rows with certain background color?


Chip and Rob,

Thank you both for the lighting speed response and solution.

Here's some further questions if you don't mind, also consider I've
never used ASP before but know a bit about programming. So, things like
reset "vbRed" to "vbYellow" would be easy for me but ...

Goal A is to 1) identify rows with background color yellow, so, I now
how to handle it;
2) add 'y' to the first cell in the row;
Goal B: 1) using ASP to set up a datasource connection to the
spreadsheet;
2) add/update 'y' to the first cell in the row with yellow background

If not much trouble, I'd appreciate further help. Many thanks in
advance.

Don









*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Identify rows with certain background color?

Don,

So in my code:
....
If rng.Interior.Color = vbRed Or rng.Interior.Color = vbYellow Then
rng.Cells(1, 1).Value = "y"
....

I don't have IIS running, so I can't help with ASP data sources, sorry.

Rob


"Don Li" wrote in message
...

Chip and Rob,

Thank you both for the lighting speed response and solution.

Here's some further questions if you don't mind, also consider I've
never used ASP before but know a bit about programming. So, things like
reset "vbRed" to "vbYellow" would be easy for me but ...

Goal A is to 1) identify rows with background color yellow, so, I now
how to handle it;
2) add 'y' to the first cell in the row;
Goal B: 1) using ASP to set up a datasource connection to the
spreadsheet;
2) add/update 'y' to the first cell in the row with yellow background

If not much trouble, I'd appreciate further help. Many thanks in
advance.

Don









*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





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
Checkbox to change background color, font color and remove/ add bo Sara Excel Discussion (Misc queries) 2 May 1st 23 11:43 AM
find excel rows with a background color Lou Excel Discussion (Misc queries) 4 May 24th 07 01:27 AM
Default Border, Font Color, and Cell Background Color Elijah Excel Discussion (Misc queries) 1 October 28th 05 04:10 PM
can you select rows in excel with a certain background color? stelee Excel Worksheet Functions 1 August 3rd 05 04:04 PM
Background color for 50,000 odd-numbered rows lothario[_42_] Excel Programming 4 November 2nd 03 05:39 AM


All times are GMT +1. The time now is 04:56 PM.

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"