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 a specific word in a column

I need to find the last occurrence of the word "Total" in a column. I can
find the last used cell in the column but failed when I tried to start the
search up from that point to find Total. Can anyone help? TIA.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Find a specific word in a column

Something like this?...

Sub test()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range

Set wks = ActiveSheet
Set rngToSearch = wks.Columns("A")


Set rngFound = rngToSearch.Find(What:="Total", _
After:=wks.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
If Not rngFound Is Nothing Then rngFound.Select
End Sub
--
HTH...

Jim Thomlinson


"cottage6" wrote:

I need to find the last occurrence of the word "Total" in a column. I can
find the last used cell in the column but failed when I tried to start the
search up from that point to find Total. Can anyone help? TIA.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find a specific word in a column

First select the column and then run:

Sub mac()
Dim s As String
Dim r As Range
Dim l As Long
s = "Total"
l = 0
For Each r In Selection
If InStr(r, s) Then
l = r.Row
End If
Next
MsgBox l
End Sub
--
Gary''s Student


"cottage6" wrote:

I need to find the last occurrence of the word "Total" in a column. I can
find the last used cell in the column but failed when I tried to start the
search up from that point to find Total. Can anyone help? TIA.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Find a specific word in a column

try this ARRAY formula
=MAX(IF(D1:D100="Total",ROW(D1:D100)))

or
Sub findlasttotal()
For I = 20 To 1 Step -1
If UCase(Cells(I, "d")) = "TOTAL" Then
MsgBox Cells(I, "d").Row: Exit Sub
End If
Next
End Sub

--
Don Guillett
SalesAid Software

"cottage6" wrote in message
...
I need to find the last occurrence of the word "Total" in a column. I can
find the last used cell in the column but failed when I tried to start the
search up from that point to find Total. 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
how we find specific word from string in excel and compaire it. Vishnu Excel Worksheet Functions 2 April 18th 09 07:51 AM
Insert pagebreak when a specific word appears in a column. Neal Excel Discussion (Misc queries) 4 October 27th 08 11:17 PM
How do I select cells within a column that contain a specific word Tobias Excel Worksheet Functions 1 September 28th 07 06:50 PM
Finding specific word in column Phil #3 Excel Worksheet Functions 3 March 28th 05 09:00 AM
Macro to search a column for a specific word and replace with wendy Excel Programming 5 January 19th 04 05:41 PM


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