View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
dcottrell505[_2_] dcottrell505[_2_] is offline
external usenet poster
 
Posts: 1
Default jumping to a cell which matches user specified text


Try this...


wscount = Workbooks("workbookName.xls").Worksheets.Count
line1: item = InputBox("Input what you would like to search for." )

'designate the column number and column header name to search in
col = 4
ColName = "Header_Name"


With Workbooks("workbookName.xls").Worksheets("sheet1") .Range("A1")
Numrows = Range(.Offset(1, col), .End(xlDown)).Rows.Count
Range(.Offset(1, col), .Offset(1, col).End(xlDown)).Name =
ColName
End With

Worksheets("sheet1").Activate
With Range(ColName)
Set c = .Find(item, LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.address
Do
'the next two lines identify the item by bolding and coloring each
instance found
c.Font.Bold = True
c.Font.ColorIndex = 3
Count = Count + 1
'this puts the address of each instance of the search item into an
array
address(Count) = c.address
Range(c.address).select
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.address <
firstaddress
End If
End With
'if no instances of item are found go back to the input box
If Count = 0 Then GoTo line1


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements