Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old March 25th 19, 07:07 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2009
Posts: 55
Default Macro to find/report text in several files at once needs translationfor finding colored cells on the same way

Dear people that are better in VBA then me

A period ago I'd got a macro to find a specific text in a few files and the macro reported then in a new file where and in which files/sheets/cells the text was found. Really (for me) a spectacular code that works very well and helps me out to find/report text quickly.

Now another question came up which needs to find/report on the same way as it is now with text, but then to report a specific color found in several files.

In below code the part;
Range("B2").Select '(In B2 the search text is registered, like "AA1234")
aay = Range("B2").Value

Should be like B2 = Color of the cell to search.

If somebody could rewrite the code so it works for colors identical as for text it would be great

regards, Johan


'---------------------------------------
Sub SearchFoldersFollowUp()
Dim aax
Dim aay

Dim fso As Object
Dim fld As Object
Dim strSearch As String
Dim strPath As String
Dim strFile As String
Dim wOut As Worksheet
Dim wbk As Workbook
Dim wks As Worksheet
Dim lRow As Long
Dim rFound As Range
Dim strFirstAddress As String

On Error GoTo ErrHandler
Application.ScreenUpdating = False


'File/Directory with the Searchtext
Windows("ExcelSearch.xlsm").Activate
Sheets("BasisSheet").Select
Range("B1").Select '(In B1 the path of the search files is registered, like "c:\apps\excelsearch")
aax = Range("B1").Value
Range("B2").Select '(In B2 the search text is registered, like "AA1234")
aay = Range("B2").Value

strPath = "" & aax
strSearch = "" & aay

Set wOut = Worksheets.Add
lRow = 1
With wOut
.Cells(lRow, 1) = "Workbook"
.Cells(lRow, 2) = "Worksheet"
.Cells(lRow, 3) = "Cell"
.Cells(lRow, 4) = "Text in Cell"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(strPath)

strFile = Dir(strPath & "\*.xls*")
Do While strFile < ""
Set wbk = Workbooks.Open _
(Filename:=strPath & "\" & strFile, _
UpdateLinks:=0, _
ReadOnly:=True, _
AddToMRU:=False)

For Each wks In wbk.Worksheets
Set rFound = wks.UsedRange.Find(strSearch)
If Not rFound Is Nothing Then
strFirstAddress = rFound.Address
End If
Do
If rFound Is Nothing Then
Exit Do
Else
lRow = lRow + 1
.Cells(lRow, 1) = wbk.Name
.Cells(lRow, 2) = wks.Name
.Cells(lRow, 3) = rFound.Address
.Cells(lRow, 4) = rFound.Value
End If
Set rFound = wks.Cells.FindNext(After:=rFound)
Loop While strFirstAddress < rFound.Address
Next

wbk.Close (False)
strFile = Dir
Loop
.Columns("A").EntireColumn.AutoFit
End With
MsgBox "Done"

ExitHandler:
Set wOut = Nothing
Set wks = Nothing
Set wbk = Nothing
Set fld = Nothing
Set fso = Nothing
Application.ScreenUpdating = True
Exit Sub

ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
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
Count and report the number of red colored cells in a row [email protected] Excel Programming 3 November 19th 16 09:38 AM
Search All Files Find Newest One Report To Excel 2007 Stever Excel Programming 1 September 6th 07 02:24 AM
Some cells have been colored and should be replaced by text basha Excel Worksheet Functions 1 April 20th 07 04:09 PM
Find colored cells in a worksheet VTN Excel Worksheet Functions 7 February 9th 07 07:41 AM
Cell right next to colored cells is automatically colored on entering a value Johan De Schutter Excel Programming 6 September 12th 03 05:31 PM


All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017