Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Help in highlighting and displaying found data.

I need to modify a macro. This macro finds the first instance of a name
and then displays a dialog box telling the user that it has found the name
and it's row location. I need the macro to Select the row that it has found
(so the user can see it on the screen.) or at least scroll so it is visible.
It would be good to highlight it in some manner.

Here is the macro as it is now:

'Sub FindPastDue()

' FindPastDue Macro

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set namerange = Range(Cells(1, "A"), Cells(Lastrow, "A"))

SearchName = InputBox("Enter Name to Find: ")

Set C = namerange.Find(SearchName, LookIn:=xlValues)

If Not C Is Nothing Then

MsgBox ("Found name: " & c & " on line " & CStr(c.Row))

Else
MsgBox ("Did not find: " & SearchName)
End If


'
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help in highlighting and displaying found data.

How about:

Option Explicit
Sub FindPastDue()

Dim LastRow As Long
Dim wks As Worksheet
Dim NameRange As Range
Dim FoundCell As Range
Dim SearchName As String

Set wks = ActiveSheet

With wks
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
'just another way
Set NameRange = .Range("A1:A" & LastRow)
End With

SearchName = InputBox("Enter Name to Find: ")

With NameRange
Set FoundCell = .Cells.Find(what:=SearchName, _
LookAt:=xlWhole, _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)
End With

If FoundCell Is Nothing Then
MsgBox "Did not find: " & SearchName
Else
MsgBox "Found Name: " & SearchName & " on line: " & FoundCell.Row
Application.Goto FoundCell, scroll:=True
End If

End Sub

jonco wrote:

I need to modify a macro. This macro finds the first instance of a name
and then displays a dialog box telling the user that it has found the name
and it's row location. I need the macro to Select the row that it has found
(so the user can see it on the screen.) or at least scroll so it is visible.
It would be good to highlight it in some manner.

Here is the macro as it is now:

'Sub FindPastDue()

' FindPastDue Macro

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set namerange = Range(Cells(1, "A"), Cells(Lastrow, "A"))

SearchName = InputBox("Enter Name to Find: ")

Set C = namerange.Find(SearchName, LookIn:=xlValues)

If Not C Is Nothing Then

MsgBox ("Found name: " & c & " on line " & CStr(c.Row))

Else
MsgBox ("Did not find: " & SearchName)
End If

'
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Help in highlighting and displaying found data.

Try this:

'Sub FindPastDue()

' FindPastDue Macro

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set namerange = Range(Cells(1, "A"), Cells(Lastrow, "A"))

SearchName = InputBox("Enter Name to Find: ")

Set C = namerange.Find(SearchName, LookIn:=xlValues)

If Not C Is Nothing Then

MsgBox ("Found name: " & c & " on line " & CStr(c.Row))
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = Cstr(C.Row)

Else
MsgBox ("Did not find: " & SearchName)
End If


'
End Sub


"jonco" wrote:

I need to modify a macro. This macro finds the first instance of a name
and then displays a dialog box telling the user that it has found the name
and it's row location. I need the macro to Select the row that it has found
(so the user can see it on the screen.) or at least scroll so it is visible.
It would be good to highlight it in some manner.

Here is the macro as it is now:

'Sub FindPastDue()

' FindPastDue Macro

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set namerange = Range(Cells(1, "A"), Cells(Lastrow, "A"))

SearchName = InputBox("Enter Name to Find: ")

Set C = namerange.Find(SearchName, LookIn:=xlValues)

If Not C Is Nothing Then

MsgBox ("Found name: " & c & " on line " & CStr(c.Row))

Else
MsgBox ("Did not find: " & SearchName)
End If


'
End Sub



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
Highlighting Data IF... NPell Excel Worksheet Functions 2 April 7th 08 11:30 AM
Found Cell Highlighting after Search ULNazarene Excel Discussion (Misc queries) 1 August 21st 07 07:31 PM
highlighting rows when a value has been found mike Excel Programming 4 November 10th 05 01:00 PM
Highlighting Found Text in Excel Wordgeek Excel Discussion (Misc queries) 1 September 13th 05 01:32 PM
Highlighting blanks via GO TO SPECIAL is not highlighting blank cells - HELP, I'm totally stuck. Jamie Furlong Excel Discussion (Misc queries) 6 August 28th 05 09:27 PM


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