Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Find string and format 54 columns to right

Hi All

I'm trying to write code that looks in column A and finds the word "total"
(which has words before or after it in the same cell, plus could be in upper
or lower case).

Whenever "total" is found I need it and the 56 columns to it's right
selected and formatted with the following:

With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With

I tried this code, but it won't pick up the "string" in a cell and I don't
know how to change the code so it does that:

Columns("A:A").Select
For Each oCell In ActiveSheet.UsedRange
If oCell = "*Total*" Then
Range(oCell.Offset(1, 0), oCell.Offset(0, 54)).Select
With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With
End If
Next oCell

Any help would be greatly appreciated.
--
Thank for your help
BeSmart
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Find string and format 54 columns to right

why not just use Conditional Formatting?
Select column 56 and select Format/Conditional Formatting
set "Formula Is" to

=($A1="Total")





"BeSmart" wrote:

Hi All

I'm trying to write code that looks in column A and finds the word "total"
(which has words before or after it in the same cell, plus could be in upper
or lower case).

Whenever "total" is found I need it and the 56 columns to it's right
selected and formatted with the following:

With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With

I tried this code, but it won't pick up the "string" in a cell and I don't
know how to change the code so it does that:

Columns("A:A").Select
For Each oCell In ActiveSheet.UsedRange
If oCell = "*Total*" Then
Range(oCell.Offset(1, 0), oCell.Offset(0, 54)).Select
With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With
End If
Next oCell

Any help would be greatly appreciated.
--
Thank for your help
BeSmart

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Find string and format 54 columns to right

IF you do want a VBA solution, then this is it:

Sub FormatTotal()
Dim address As String
Dim found As Range
Set found = Range("A:A").Find("Total")
If Not found Is Nothing Then
address = found.address
Do


With Cells(found.Row, 56)
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With
Set found = Range("A:A").FindNext(found)
Loop Until found.address = address
End If
End Sub

"Patrick Molloy" wrote:

why not just use Conditional Formatting?
Select column 56 and select Format/Conditional Formatting
set "Formula Is" to

=($A1="Total")





"BeSmart" wrote:

Hi All

I'm trying to write code that looks in column A and finds the word "total"
(which has words before or after it in the same cell, plus could be in upper
or lower case).

Whenever "total" is found I need it and the 56 columns to it's right
selected and formatted with the following:

With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With

I tried this code, but it won't pick up the "string" in a cell and I don't
know how to change the code so it does that:

Columns("A:A").Select
For Each oCell In ActiveSheet.UsedRange
If oCell = "*Total*" Then
Range(oCell.Offset(1, 0), oCell.Offset(0, 54)).Select
With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With
End If
Next oCell

Any help would be greatly appreciated.
--
Thank for your help
BeSmart

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Find string and format 54 columns to right

Hi,
does this work?
change:
If oCell = "*Total*" Then
to:
If oCell like "*Total*" Then

?
OJ

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Find string and format 54 columns to right

Besmart

You have 54 columns in the subject and 56 in the text. This does 56

Sub FindTotal()
Dim lLastRow As Long
Dim myCell As Range
lLastRow = Range("A65536").End(xlUp).Row
For Each myCell In Range("A1:A" & lLastRow)
If InStr(1, UCase(myCell.Value), "TOTAL") 0 Then
With myCell.Resize(1, 56)
.Font.Bold = True
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With
End If
Next myCell
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"BeSmart" wrote in message
...
Hi All

I'm trying to write code that looks in column A and finds the word "total"
(which has words before or after it in the same cell, plus could be in
upper
or lower case).

Whenever "total" is found I need it and the 56 columns to it's right
selected and formatted with the following:

With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With

I tried this code, but it won't pick up the "string" in a cell and I don't
know how to change the code so it does that:

Columns("A:A").Select
For Each oCell In ActiveSheet.UsedRange
If oCell = "*Total*" Then
Range(oCell.Offset(1, 0), oCell.Offset(0, 54)).Select
With Selection
.Font.FontStyle = "Bold"
.Font.ColorIndex = 2
.Interior.ColorIndex = 47
End With
End If
Next oCell

Any help would be greatly appreciated.
--
Thank for your help
BeSmart





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
Find String in another string - only between spaces Nir Excel Worksheet Functions 9 November 2nd 06 11:31 AM
Find Many String options in ONE String Nir Excel Worksheet Functions 6 October 26th 06 07:13 AM
Q: find range, listbox - format and fit columns Mark[_17_] Excel Programming 0 June 8th 04 12:41 PM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM
find a string inside another string MarkS Excel Programming 1 January 13th 04 02:55 AM


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