Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Select Entire Row if Text is Red

My macro, below, is not working:
Sub SelIfRed()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If cell.Font.ColorIndex = 3 Then ' Change if not correct value for
rng.EntireRow.Select
End If
Next c
End Sub

It fails he
If cell.Font.ColorIndex = 3 Then

I can't see what the problem is. Can anyone see something that I'm not
seeing?
Thanks,
Ryan---

--
RyGuy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Select Entire Row if Text is Red

If c.Font.ColorIndex = 3 Then
c.EntireRow.Select


because you are looping on the c range variable
--
Gary''s Student - gsnu200752


"ryguy7272" wrote:

My macro, below, is not working:
Sub SelIfRed()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If cell.Font.ColorIndex = 3 Then ' Change if not correct value for
rng.EntireRow.Select
End If
Next c
End Sub

It fails he
If cell.Font.ColorIndex = 3 Then

I can't see what the problem is. Can anyone see something that I'm not
seeing?
Thanks,
Ryan---

--
RyGuy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Select Entire Row if Text is Red

Thanks GS! That solved the problem with the error, but it just loops through
all cells in the selected range, and ends on the last row with red text in
it. I guess the issue is more complicated that that, because when the Sub
ends, only one row is selected. Now, I am working with the code below, and
again it is giving me a problem. Does anyone have an idea about what to do
now? All I want to do is select an entire row if it has any red text in it,
and copy/paste these rows into a new sheet.


Sub Select_Red_Fonts()
Dim c As Range, SearchRange As Range, cell As Range, redFonts As Range, x

Set SearchRange = Cells.SpecialCells(xlCellTypeConstants)
For Each c In SearchRange
If cell.Font.ColorIndex = 3 Then
'c.EntireRow.Select
If x = 1 Then
Set redFonts = Union(redFonts, cell)
Else
Set redFonts = cell
x = 1
End If
End If
Next c
c.EntireRow.Select
redFonts.Select

Worksheets.Add.Name = "Summary"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub


Thanks,
Ryan---



--
RyGuy


"Gary''s Student" wrote:

If c.Font.ColorIndex = 3 Then
c.EntireRow.Select


because you are looping on the c range variable
--
Gary''s Student - gsnu200752


"ryguy7272" wrote:

My macro, below, is not working:
Sub SelIfRed()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If cell.Font.ColorIndex = 3 Then ' Change if not correct value for
rng.EntireRow.Select
End If
Next c
End Sub

It fails he
If cell.Font.ColorIndex = 3 Then

I can't see what the problem is. Can anyone see something that I'm not
seeing?
Thanks,
Ryan---

--
RyGuy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Select Entire Row if Text is Red

Answer is he
http://www.microsoft.com/office/comm...2fsettings.xml


--
RyGuy


"ryguy7272" wrote:

Thanks GS! That solved the problem with the error, but it just loops through
all cells in the selected range, and ends on the last row with red text in
it. I guess the issue is more complicated that that, because when the Sub
ends, only one row is selected. Now, I am working with the code below, and
again it is giving me a problem. Does anyone have an idea about what to do
now? All I want to do is select an entire row if it has any red text in it,
and copy/paste these rows into a new sheet.


Sub Select_Red_Fonts()
Dim c As Range, SearchRange As Range, cell As Range, redFonts As Range, x

Set SearchRange = Cells.SpecialCells(xlCellTypeConstants)
For Each c In SearchRange
If cell.Font.ColorIndex = 3 Then
'c.EntireRow.Select
If x = 1 Then
Set redFonts = Union(redFonts, cell)
Else
Set redFonts = cell
x = 1
End If
End If
Next c
c.EntireRow.Select
redFonts.Select

Worksheets.Add.Name = "Summary"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub


Thanks,
Ryan---



--
RyGuy


"Gary''s Student" wrote:

If c.Font.ColorIndex = 3 Then
c.EntireRow.Select


because you are looping on the c range variable
--
Gary''s Student - gsnu200752


"ryguy7272" wrote:

My macro, below, is not working:
Sub SelIfRed()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If cell.Font.ColorIndex = 3 Then ' Change if not correct value for
rng.EntireRow.Select
End If
Next c
End Sub

It fails he
If cell.Font.ColorIndex = 3 Then

I can't see what the problem is. Can anyone see something that I'm not
seeing?
Thanks,
Ryan---

--
RyGuy

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
why does this macro select the entire worksheet when run? Dave F Excel Discussion (Misc queries) 6 March 1st 07 01:19 PM
Select the entire row shantanu oak Excel Discussion (Misc queries) 5 July 17th 06 11:34 AM
select entire rows using a contains comparison - an example [email protected] Excel Programming 0 April 5th 06 11:43 PM
How to select entire column using VBA Phill Excel Programming 3 December 5th 03 03:44 PM
select contents of entire worksheet Dave[_22_] Excel Programming 5 August 1st 03 04:17 PM


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