Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Outlook 2002 calendar dates exported to Excel 2002 sort incorrectl | Excel Worksheet Functions | |||
ListView to Excel Code (but needs SPEED improvements) | Excel Programming | |||
Listview in Excel 97 vba. | Excel Programming | |||
Get items in ListView in columns | Excel Programming | |||
Description of Listview and Treeview Controls | Excel Programming |