LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel 2002: Need help with Listview

Okay Excel gurus.... I'm gonna cry "uncle" and admit that I've hit
wall with this one.

What I'm trying to do is create my own kind of search program. I'v
got a UserForm with a ListView control on it. The ListView control ha
4 columns. The code below (some of which has come from this forum
prompts the user for a word to find. What it's *supposed* to do i
this: For every instince of the word that is found, add an entry int
the ListView with the following information for each column:
1) How many have been found (if there are three, there should be thre
entries; 1, 2 & 3)
2) The Sheet name
3) The cell address
4) The text that was found

And here's the code that I've got so far.
Any help will be greatly appreciated!

Thanks in advance!

Option Explicit


Private Sub UserForm_Initialize()
Dim oSheet As Object
Dim Firstcell As Range
Dim NextCell As Range
Dim WhatToFind As Variant
Dim blnFound As Boolean
Dim strSearchText As String
Dim i As Integer
i = 1
Dim li As ListItem
Dim list As Variant

lvwSearchResults.ListItems.Clear
Set li = lvwSearchResults.ListItems.Add()

WhatToFind = Application.InputBox("What are you looking for ?"
"Search", , 100, 100, , , 2)
If WhatToFind < "" And Not WhatToFind = False Then
For Each oSheet In ActiveWorkbook.Worksheets
oSheet.Activate
oSheet.[a1].Activate
Set Firstcell = Cells.Find(What:=WhatToFind
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows
SearchDirection:=xlNext, MatchCase:=False)
If Not Firstcell Is Nothing Then
Firstcell.Activate
strSearchText = strSearchText & vbCr & WhatToFind &
in " & oSheet.Name & "!" & Firstcell.Address
li.Text = "~"
li.ListSubItems.Add , , oSheet.Name
li.ListSubItems.Add , , Firstcell.Address
li.ListSubItems.Add , , WhatToFind
On Error Resume Next
While (Not NextCell Is Nothing) And (No
NextCell.Address = Firstcell.Address)
Set NextCell = Cells.FindNext(After:=ActiveCell)
If Not NextCell.Address = Firstcell.Address Then
NextCell.Activate
strSearchText = strSearchText & vbCr
WhatToFind & " in " & oSheet.Name & "!" & NextCell.Address
li.Text = "~"
li.ListSubItems.Add , , oSheet.Name
li.ListSubItems.Add , , Firstcell.Address
li.ListSubItems.Add , , WhatToFind
End If
i = i + 1
Wend
End If
Set NextCell = Nothing
Set Firstcell = Nothing
i = i + 1
Next oSheet
End If
' MsgBox strSearchText
End Su

--
Message posted from http://www.ExcelForum.com

 
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
Outlook 2002 calendar dates exported to Excel 2002 sort incorrectl scampbell Excel Worksheet Functions 0 February 22nd 06 06:31 PM
ListView to Excel Code (but needs SPEED improvements) SVD Excel Programming 1 February 2nd 04 10:54 AM
Listview in Excel 97 vba. jaxrpc Excel Programming 3 January 1st 04 03:04 PM
Get items in ListView in columns RB Smissaert Excel Programming 3 October 20th 03 12:39 PM
Description of Listview and Treeview Controls Frank[_12_] Excel Programming 1 August 14th 03 08:40 AM


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