Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Expand a range

Hi everyone,
I need to find rows in Col. A with the word "Wire" as the 1st four
characters, and then bold and turn red that cell along with the cells to the
right of it all the way over to Col. K (not the whole row). I have the first
part of the macro figured out, but am unsure how to expand the range to
include the extra columns to the right. I can do it using Column Offset but
that seems awfully clunky to me and I want to do this the right way. Here's
what I have so far, and thanks for any help you can provide!

Sub BoldTheRows()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set CompareRange = Range("A1:A" & LastRow)
For Each cell In CompareRange
If Left(cell, 4) = "WIRE" Then
With cell
..Font.Bold = True
..Font.ColorIndex = 3
End With
End If
Next cell
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Expand a range

Change your With statement from this...

With cell

to this....

With cell.Resize(1, 11)

Rick


"cottage6" wrote in message
...
Hi everyone,
I need to find rows in Col. A with the word "Wire" as the 1st four
characters, and then bold and turn red that cell along with the cells to
the
right of it all the way over to Col. K (not the whole row). I have the
first
part of the macro figured out, but am unsure how to expand the range to
include the extra columns to the right. I can do it using Column Offset
but
that seems awfully clunky to me and I want to do this the right way.
Here's
what I have so far, and thanks for any help you can provide!

Sub BoldTheRows()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set CompareRange = Range("A1:A" & LastRow)
For Each cell In CompareRange
If Left(cell, 4) = "WIRE" Then
With cell
.Font.Bold = True
.Font.ColorIndex = 3
End With
End If
Next cell
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Expand a range

Maybe not the best way to do it but one that would work is to run a for next
statement that would go through and check column a and then change the color
for the rest of the row to red if column a starts with wire. See below.

dim x as integer
dim strIsItWire as string

For x = 2 to LastRow
strIsItWire = Range("A" & x).Value
If Left(strIsItWire, 4) = "WIRE" Then
Range("A" & x & ":K" & x).Select
With Selection
.Font.Bold = True
.Font.ColorIndex = 3
End With
End If
Next


cottage6 wrote:
Hi everyone,
I need to find rows in Col. A with the word "Wire" as the 1st four
characters, and then bold and turn red that cell along with the cells to the
right of it all the way over to Col. K (not the whole row). I have the first
part of the macro figured out, but am unsure how to expand the range to
include the extra columns to the right. I can do it using Column Offset but
that seems awfully clunky to me and I want to do this the right way. Here's
what I have so far, and thanks for any help you can provide!

Sub BoldTheRows()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set CompareRange = Range("A1:A" & LastRow)
For Each cell In CompareRange
If Left(cell, 4) = "WIRE" Then
With cell
.Font.Bold = True
.Font.ColorIndex = 3
End With
End If
Next cell
End Sub


--
Message posted via http://www.officekb.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Expand a range

Thanks to both of you for your solutions. Rick, always good to hear from you

"Rick Rothstein (MVP - VB)" wrote:

Change your With statement from this...

With cell

to this....

With cell.Resize(1, 11)

Rick


"cottage6" wrote in message
...
Hi everyone,
I need to find rows in Col. A with the word "Wire" as the 1st four
characters, and then bold and turn red that cell along with the cells to
the
right of it all the way over to Col. K (not the whole row). I have the
first
part of the macro figured out, but am unsure how to expand the range to
include the extra columns to the right. I can do it using Column Offset
but
that seems awfully clunky to me and I want to do this the right way.
Here's
what I have so far, and thanks for any help you can provide!

Sub BoldTheRows()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set CompareRange = Range("A1:A" & LastRow)
For Each cell In CompareRange
If Left(cell, 4) = "WIRE" Then
With cell
.Font.Bold = True
.Font.ColorIndex = 3
End With
End If
Next cell
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Expand a range

Rick, always good to hear from you

The way you said that makes me think I have helped you before over in the
compiled VB newsgroups... is that the case (sorry if I don't remember you,
but the name "cottage6" doesn't ring a bell)?

Rick



Change your With statement from this...

With cell

to this....

With cell.Resize(1, 11)

Rick


"cottage6" wrote in message
...
Hi everyone,
I need to find rows in Col. A with the word "Wire" as the 1st four
characters, and then bold and turn red that cell along with the cells
to
the
right of it all the way over to Col. K (not the whole row). I have the
first
part of the macro figured out, but am unsure how to expand the range to
include the extra columns to the right. I can do it using Column
Offset
but
that seems awfully clunky to me and I want to do this the right way.
Here's
what I have so far, and thanks for any help you can provide!

Sub BoldTheRows()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set CompareRange = Range("A1:A" & LastRow)
For Each cell In CompareRange
If Left(cell, 4) = "WIRE" Then
With cell
.Font.Bold = True
.Font.ColorIndex = 3
End With
End If
Next cell
End Sub






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Expand a range

You help me all the time; on 3/13/08 with "Input Box Help", on 5/2/08 with
"Get date from prior sheet", and with an awesome user form that pops up a
list of files, just to name a few. I'm not sure what you mean by compiled VB
newsgroups, but thanks again for all your help.

"Rick Rothstein (MVP - VB)" wrote:

Rick, always good to hear from you


The way you said that makes me think I have helped you before over in the
compiled VB newsgroups... is that the case (sorry if I don't remember you,
but the name "cottage6" doesn't ring a bell)?

Rick



Change your With statement from this...

With cell

to this....

With cell.Resize(1, 11)

Rick


"cottage6" wrote in message
...
Hi everyone,
I need to find rows in Col. A with the word "Wire" as the 1st four
characters, and then bold and turn red that cell along with the cells
to
the
right of it all the way over to Col. K (not the whole row). I have the
first
part of the macro figured out, but am unsure how to expand the range to
include the extra columns to the right. I can do it using Column
Offset
but
that seems awfully clunky to me and I want to do this the right way.
Here's
what I have so far, and thanks for any help you can provide!

Sub BoldTheRows()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set CompareRange = Range("A1:A" & LastRow)
For Each cell In CompareRange
If Left(cell, 4) = "WIRE" Then
With cell
.Font.Bold = True
.Font.ColorIndex = 3
End With
End If
Next cell
End Sub




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
Range that expand Juran Excel Discussion (Misc queries) 1 August 8th 06 01:52 AM
Expand range help David Excel Programming 2 July 27th 06 01:34 AM
Cannot Expand Named Range - when size of the Range exceeds Snig Excel Discussion (Misc queries) 1 July 7th 05 01:46 PM
Expand Range WStoreyII Excel Programming 2 December 6th 04 12:48 PM
Find first cell in range and expand range -VBA Caméléon Excel Programming 3 December 4th 04 02:01 AM


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