Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
text in file
I am looking for a fast and efficient method to verify if a text
string exists in a file. Has anyone created anything like this? The files are typically under 100K but I will be doing thousands of checks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
text in file
You can try this
Sub Test() Dim i As String i = InputBox("Find:", "Search For Value") Cells.Find(What:=i, After:=Range("A1"), LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate If ActiveCell.Value = i Then MsgBox i & " was found in cell " & ActiveCell.Address End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
text in file
Modified it to search your whole workbook. Ofcourse you can hardcode
the string you would like to search for and remove the input box, and also modify the way you would like to identify the found results. Sub Test() Dim i As String Dim n As Single i = InputBox("Find:", "Search For Value") For n = 1 To Sheets.Count Sheets(n).Select 'Activate On Error Resume Next With cells .Find(What:=i, After:=Range("A1"), LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate End With If ActiveCell.Value = i Then MsgBox i & " was found in cell " & ActiveCell.Address Exit Sub Else End If Next n End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
text in file
Oops, sorry. I needed to mention that the file being searched is a simple text file. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
text in file
Use native VBA functions or the FileSystemObject to read the file into a
string variable, then use instr() to check for your text. Tim "codie" wrote in message ... Oops, sorry. I needed to mention that the file being searched is a simple text file. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to tell number of spaces between values in saved text file fromthe original xls file | Excel Discussion (Misc queries) | |||
Saving multi-tab excel file created from comma delimited text file | Excel Programming | |||
How do I import text file, analyze data, export results, open next file | Excel Programming | |||
Excel VBA - open text file, replace text, save file? | Excel Programming | |||
importing text file, removing data and outputting new text file | Excel Programming |