Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Return the row number of a cell if its interior color = 50

I have a worksheet that I need to delete rows. The first row is always 10,
but the second row can vary past 10. I was wondering if there is quick
function or cleaner way of writing code to find the last row in Col.B that
contains an interior colorindex = 50? This is what I have.

Sub DeleteRows()

' find green line at end of quote sheet
lngLastRow = 10
Do Until Cells(lngLastRow, 2).Interior.ColorIndex = 50
lngLastRow = lngLastRow + 1
Loop

' delete rows (items) from quote sheet
Rows("10:" & lngLastRow).Delete Shift:=xlUp

End Sub
--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Return the row number of a cell if its interior color = 50

The loop is in principle good.

From Excel 2002 onwards (if I'm not mistaken) you can search on formatting
of a cell with the usual Ctrl-F (you can program that as well in VBA).

Another option is, if the color is set with some logic behind it. Then that
logic could perhaps be used in an autofilter or a regular Find in VBA.

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"RyanH" wrote:

I have a worksheet that I need to delete rows. The first row is always 10,
but the second row can vary past 10. I was wondering if there is quick
function or cleaner way of writing code to find the last row in Col.B that
contains an interior colorindex = 50? This is what I have.

Sub DeleteRows()

' find green line at end of quote sheet
lngLastRow = 10
Do Until Cells(lngLastRow, 2).Interior.ColorIndex = 50
lngLastRow = lngLastRow + 1
Loop

' delete rows (items) from quote sheet
Rows("10:" & lngLastRow).Delete Shift:=xlUp

End Sub
--
Cheers,
Ryan

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
Cell interior color JohnB Excel Discussion (Misc queries) 4 October 12th 06 06:07 PM
Cell background color (interior color) setting not working Martin E. Excel Programming 1 May 21st 06 07:00 PM
interior color of a cell R.VENKATARAMAN Excel Programming 9 November 11th 05 04:15 AM
Interior Cell color Pellechi Excel Programming 1 September 23rd 03 03:39 PM


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