LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Finding Cell Contents

Here is my code so far.

Private Sub CommandButton1_Click()
Dim rng As Range, rng1 As Range
Dim cell As Range
Set rng = Range(Cells(1, "O"), Cells(Rows.Count, "O").End(xlUp))
For Each cell In rng
If cell.Font.ColorIndex = 6 Or cell.Font.ColorIndex = 3 Then
If rng1 Is Nothing Then
Set rng1 = cell
Else
Set rng1 = Union(rng1, cell)
End If
End If
Next cell
If Not rng1 Is Nothing Then
rng1.EntireRow.Copy Destination:= _
Worksheets("Sheet3").Cells(Rows.Count, 1).End(xlUp)
Else
MsgBox "No cells met criteria"
End If

This copys a row if the font in column O is red or yellow.
I am also trying to see if it has text in columns A or B and if there is no
contents, I want it to copy the cell above it.
For example:
A B -------------------------
O
5 1 1
6 1
7
8
red font

The code would then copy cells A5 & B6 to A8 & B8 on the other sheet
 
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
Finding the Row number based on contents of a cell Chris Youlden Excel Worksheet Functions 5 September 6th 07 04:38 PM
finding the cell with min value and returning the contents of neig Will Excel Worksheet Functions 1 May 17th 07 10:18 PM
Finding row # of last cell containing contents Bob Excel Worksheet Functions 7 January 8th 07 07:13 PM
Finding cell contents based on certain criteria thekovinc Excel Discussion (Misc queries) 1 March 15th 06 07:37 PM
Finding cell contents based on certain criteria thekovinc Excel Discussion (Misc queries) 1 March 15th 06 07:20 PM


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