Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Find cells containing "Total"

Hello all,
How can I find all cells with the word "Total" included in the cell? For
example, one of the cells is "6/3/2006 Total", with "Total" always being the
last 5 characters. I've tried several things but nothing's worked. Can
anyone help? TIA

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Find cells containing "Total"

Dim tCell as Range 'Cell Containing Total
Dim ftCell as Range 'Cell Containg First Total
Set ftCell = Cells.Find(What:="Total", After:=Range("A1"),
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
if ftCell is Nothing Then End Sub
Set tCell = ftCell
Do
'Your Code
Set tCell = Cells.Find(What:="Total", After:=tCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
Loop Until tCell.Address = ftCell.Address

HTH

Die_Another_Day
cottage6 wrote:
Hello all,
How can I find all cells with the word "Total" included in the cell? For
example, one of the cells is "6/3/2006 Total", with "Total" always being the
last 5 characters. I've tried several things but nothing's worked. Can
anyone help? TIA


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Find cells containing "Total"

Give this a try...

Sub FindTotal()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String

Set wks = Sheets("Sheet1")
Set rngToSearch = wks.Cells
Set rngFound = rngToSearch.Find(What:="Total", _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Total was not found."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.Select
End If

End Sub
--
HTH...

Jim Thomlinson


"cottage6" wrote:

Hello all,
How can I find all cells with the word "Total" included in the cell? For
example, one of the cells is "6/3/2006 Total", with "Total" always being the
last 5 characters. I've tried several things but nothing's worked. Can
anyone help? TIA

  #4   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Find cells containing "Total"

Try this:

Dim myCell As Range
Dim firstCell As String

'set first search
Set myCell = Cells.Find(What:="Total")

If Not myCell Is Nothing Then
'do something
firstCell = myCell.Address
MsgBox myCell.Value
'continue searching
Do
Set myCell = Cells.FindNext(myCell)
If Not myCell Is Nothing And myCell.Address < firstCell Then
'do something again
MsgBox myCell.Value
End If
Loop While Not myCell Is Nothing And myCell.Address < firstCell

End If


--
Les Torchia-Wells


"cottage6" wrote:

Hello all,
How can I find all cells with the word "Total" included in the cell? For
example, one of the cells is "6/3/2006 Total", with "Total" always being the
last 5 characters. I've tried several things but nothing's worked. Can
anyone help? TIA

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
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Linking two "total" pages to create a "Complete Total" page Jordon Excel Worksheet Functions 0 January 10th 06 11:18 PM
Find the word "total" in a cell, delete row or column Lawlerd[_2_] Excel Programming 1 October 20th 04 02:32 PM
Find the word "total" in a cell, delete row or column Lawlerd Excel Programming 1 October 20th 04 12:02 PM
Search "Total" in all worksheets and delete rows containing "Total" mk_garg20 Excel Programming 2 July 30th 04 06:42 AM


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