Hi all,
I'm looking for help to create Macro to open contents in folder and search for the word "troubleshoot" in each file. The folder contains 287; having to open all the files is time consuming.
Thanks in advance.
Hi all,
I'm looking for help to create Macro to open contents in folder and search for the word "troubleshoot" in each file. The folder contains 287; having to open all the files is time consuming.
Thanks in advance.
So this macro will open all files in a folder:
but I don't know what you want the code to do WHEN/IF it finds troubleshoot anywhere. What are you wanting at that point?![]()
Sub OpenFiles() Dim MyFolder As String Dim MyFile As String MyFolder = "\\G:\Functional Teams\Finance\2013\Consolidation & Reporting\1013\Financial Package" MyFile = Dir(MyFolder & "\*.xls") Do While MyFile <> "" Workbooks.Open Filename:=MyFolder & "\" & MyFile MyFile = Dir Loop End Sub
Also is there a set number of sheets in each file, do they have only one sheet or multiple variable worksheets?
Last edited by mikeTRON; 07-11-2014 at 12:38 PM.
Please ensure you mark your thread as Solved once it is. Click here to see how.
If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.
This will open all folders and search each cell in columns A:IV for the word troubleshoot however exactly what miektron said what do you want it to do when you find the word?
![]()
Sub openallfilesinfolder() Dim MyFolder As String Dim MyFile As String MyFolder = "C:\Users\JBRANUM\Desktop\New Folder" MyFile = Dir(MyFolder & "\*.csv") Do While MyFile <> "" Workbooks.Open Filename:=MyFolder & "\" & MyFile MyFile = Dir Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets Dim FindString As String Dim Rng As Range FindString = "troubleshoot" If Trim(FindString) <> "" Then With ActiveSheet.Range("A:IV") Set Rng = .find(What:=FindString, _ After:=.Cells(.Cells.Count), _ lookin:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not Rng Is Nothing Then Application.Goto Rng, True Else MsgBox "Nothing found" End If End With End If Next ws Loop End Sub
Thank those who have helped you by clicking the Star * below their name and please mark your post [SOLVED] if it has been answered satisfactorily.
Thanks guys!
After finding the files that contain the word "troubleshoot", I'd like to add the contents in Cell E23 into a new workbook/the workbook that contain the Macro(above).
Thanks again.
Does troubleshoot always fall in ONE particular cell?
Are there multiple sheets in each workbook?
What else can you tell us to help fine tune this thing?
Can you post a sample dataset to illustrate what you are wanting?
This checks all sheets in all files in a folder and puts the file names and cell addresses in a range.
The workbook with this code in it should not be in the same folder.
You can add the line to copy E23 into your workbook![]()
Sub CheckFiles() Const fPath As String = "E:\Some Folder\Some Folder\" '<----- Change as required Dim sh As Worksheet Dim sName As String Dim fnd As Range Dim sw As String Dim a As String With Application .Calculation = xlCalculationManual .EnableEvents = False .ScreenUpdating = False End With sName = Dir(fPath & "*.xls*") sw = ActiveSheet.Range("B6").Value '<----- B6 has the word you're looking for Do Until sName = "" With GetObject(fPath & sName) For Each sh In .Worksheets With sh Set fnd = sh.Columns(1).Find(what:=sw, Lookat:=xlPart, MatchCase:=False) If Not fnd Is Nothing Then Cells(Rows.Count, 2).End(xlUp).Offset(1) = "Found in " & sName & _ " in cell " & fnd.Address & " in sheet " & sh.Name 'If Not fnd Is Nothing Then a = "Found in " & sName & " in Sheet " & sh.Name End With Next sh .Close True End With sName = Dir Loop 'Range("B10").Value = a With Application .Calculation = xlAutomatic .EnableEvents = True .ScreenUpdating = True End With End Sub
Sorry, it checks the first column only.
You can change
to this![]()
Set fnd = sh.Columns(1).Find(what:=sw, Lookat:=xlPart, MatchCase:=False)
![]()
Set fnd = sh.Cells.Find(what:=sw, Lookat:=xlPart, MatchCase:=False)
Last edited by jolivanes; 07-11-2014 at 01:35 PM. Reason: Add info
Troubleshoot would be in a merge cell/cells, C38:T41 or C42:T45 or C46:T49 or C50:T53.
There are multiple sheets in each workbook. Sheet names are WO1, WO2 and WO3.
Ahh I must have been slow to respond, but mine is very similar to the above.
AllFilesOpen.xlsb
Thanks a lot, I really appreciate the help.
Works Great!
If it is solved can you mark it as such?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks