ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set certain rows to Bold (https://www.excelbanter.com/excel-programming/322126-set-certain-rows-bold.html)

jerry chapman[_2_]

Set certain rows to Bold
 
I want to step through all the used rows, and for those rows that have a
certain string contained in column B I want to set the row to bold. How
could I write a macro to do that?



Don Guillett[_4_]

Set certain rows to Bold
 
Look in vba HELP for FINDNEXT. There is an excellent example you can modify

--
Don Guillett
SalesAid Software

"jerry chapman" wrote in message
. com...
I want to step through all the used rows, and for those rows that have a
certain string contained in column B I want to set the row to bold. How
could I write a macro to do that?





jerry chapman[_2_]

Set certain rows to Bold
 
I looked in vba help for findnext, and it talked about a record set. I don't
see the relevenct to my question.
"Don Guillett" wrote in message
...
Look in vba HELP for FINDNEXT. There is an excellent example you can

modify

--
Don Guillett
SalesAid Software

"jerry chapman" wrote in message
. com...
I want to step through all the used rows, and for those rows that have a
certain string contained in column B I want to set the row to bold. How
could I write a macro to do that?







Tom Ogilvy

Set certain rows to Bold
 
Wrong FindNext. Here is the example code referred to:

Example
This example finds all cells in the range A1:A500 that contain the value 2
and changes their values to 5.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
om...
I looked in vba help for findnext, and it talked about a record set. I

don't
see the relevenct to my question.
"Don Guillett" wrote in message
...
Look in vba HELP for FINDNEXT. There is an excellent example you can

modify

--
Don Guillett
SalesAid Software

"jerry chapman" wrote in message
. com...
I want to step through all the used rows, and for those rows that have

a
certain string contained in column B I want to set the row to bold.

How
could I write a macro to do that?









jerry chapman[_2_]

Set certain rows to Bold
 
I don't think that really addresses my problem. I had simplified it a
little. So let me restate it.
I want to work on each row individually. In each row I want to check for a
different sequence of character in three different column. If the required
sequence is found in any of the three columns, I want to set all the columns
in that to Bold.
"Tom Ogilvy" wrote in message
...
Wrong FindNext. Here is the example code referred to:

Example
This example finds all cells in the range A1:A500 that contain the value 2
and changes their values to 5.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
om...
I looked in vba help for findnext, and it talked about a record set. I

don't
see the relevenct to my question.
"Don Guillett" wrote in message
...
Look in vba HELP for FINDNEXT. There is an excellent example you can

modify

--
Don Guillett
SalesAid Software

"jerry chapman" wrote in message
. com...
I want to step through all the used rows, and for those rows that

have
a
certain string contained in column B I want to set the row to bold.

How
could I write a macro to do that?











Dave Peterson[_5_]

Set certain rows to Bold
 
Ahhh. But you could use that shell to seach through each of the 3 columns. If
you find a match, you just bold the row.

Option Explicit
Sub testme01()

Dim myCols As Variant
Dim iCtr As Long
Dim WhatToFind As Variant
Dim c As Range
Dim FirstAddress As String

myCols = Array("a", "E", "J")
WhatToFind = Array("abcd", "efgh", "ijkl")


For iCtr = LBound(myCols) To UBound(myCols)
FirstAddress = ""
With Worksheets("sheet1").Range(myCols(iCtr) & "1").EntireColumn
Set c = .Cells.Find(what:=WhatToFind(iCtr), _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
lookat:=xlPart, _
searchdirection:=xlNext)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
c.EntireRow.Font.Bold = True
Set c = .FindNext(c)
Loop While Not c Is Nothing _
And c.Address < FirstAddress
End If
End With
Next iCtr
End Sub

Watch out for that .find command. I looked for it in any part of the cell
(xlpart vs xlwhole).

You could cycle through each of the rows and use instr() to look for a match,
but .find's can be a lot faster.



jerry chapman wrote:

I don't think that really addresses my problem. I had simplified it a
little. So let me restate it.
I want to work on each row individually. In each row I want to check for a
different sequence of character in three different column. If the required
sequence is found in any of the three columns, I want to set all the columns
in that to Bold.
"Tom Ogilvy" wrote in message
...
Wrong FindNext. Here is the example code referred to:

Example
This example finds all cells in the range A1:A500 that contain the value 2
and changes their values to 5.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
om...
I looked in vba help for findnext, and it talked about a record set. I

don't
see the relevenct to my question.
"Don Guillett" wrote in message
...
Look in vba HELP for FINDNEXT. There is an excellent example you can
modify

--
Don Guillett
SalesAid Software

"jerry chapman" wrote in message
. com...
I want to step through all the used rows, and for those rows that

have
a
certain string contained in column B I want to set the row to bold.

How
could I write a macro to do that?









--

Dave Peterson


All times are GMT +1. The time now is 03:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com