Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how we find specific word from string in excel and compaire it. | Excel Worksheet Functions | |||
Insert pagebreak when a specific word appears in a column. | Excel Discussion (Misc queries) | |||
How do I select cells within a column that contain a specific word | Excel Worksheet Functions | |||
Finding specific word in column | Excel Worksheet Functions | |||
Macro to search a column for a specific word and replace with | Excel Programming |