Solved

Is it possible to have Date Modified information included is this code

Posted on 2014-03-20
2
109 Views
Last Modified: 2014-03-21
This is a piggy back to ID: 39943167.  I would also like to add a date modified field.  Thanks!

Sub FindAll()
   Dim wks As Worksheet, wksOut As Worksheet
   Dim colFoundRanges As Collection
   Dim strFind As String
   Dim lngIndex As Long
   On Error Resume Next
   Application.DisplayAlerts = False
   Sheets("Find results").Delete
   Application.DisplayAlerts = True
   Set wksOut = Worksheets.Add
   wksOut.Name = "Find results"
   
   Set colFoundRanges = New Collection
   
   'strFind = InputBox("Enter string to find")
   strFind = ",T"
   For Each wks In ActiveWorkbook.Worksheets
      FindCells wks, strFind, colFoundRanges
   Next wks
   With colFoundRanges
      For lngIndex = 1 To .Count
         With .Item(lngIndex)
            wksOut.Cells(lngIndex, 1).Value = .Parent.Parent.Name
            wksOut.Cells(lngIndex, 2).Value = .Parent.Name
            wksOut.Cells(lngIndex, 3).Value = .Address
            wksOut.Cells(lngIndex, 4).Value = "'" & .Formula
                        
            End With
      Next lngIndex
   End With
End Sub
Sub FindCells(ws As Worksheet, strToFind As String, colOutput As Collection)
   Dim strFirstAddress As String
   Dim rngFound As Range
   With ws.UsedRange
      Set rngFound = .Find(what:=strToFind, lookat:=xlPart, LookIn:=xlFormulas, MatchCase:=False)
      If Not rngFound Is Nothing Then
         strFirstAddress = rngFound.Address
         Do
            colOutput.Add rngFound, ws.Name & "-" & rngFound.Address
            Set rngFound = .FindNext(rngFound)
         Loop While rngFound.Address <> strFirstAddress
      End If
   End With
End Sub

Open in new window

0
Comment
Question by:LMPhillips
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39944588
Hi,

pls try

Sub FindAll()
   Dim wks As Worksheet, wksOut As Worksheet
   Dim colFoundRanges As Collection
   Dim strFind As String
   Dim lngIndex As Long
   On Error Resume Next
   Application.DisplayAlerts = False
   Sheets("Find results").Delete
   Application.DisplayAlerts = True
   Set wksOut = Worksheets.Add
   wksOut.Name = "Find results"
   
   Set colFoundRanges = New Collection
   
   'strFind = InputBox("Enter string to find")
   strFind = ",T"
   For Each wks In ActiveWorkbook.Worksheets
      FindCells wks, strFind, colFoundRanges
   Next wks
   With colFoundRanges
      For lngIndex = 1 To .Count
         With .Item(lngIndex)
            wksOut.Cells(lngIndex, 1).Value = .Parent.Parent.Name
            wksOut.Cells(lngIndex, 2).Value = Format(FileDateTime(.Parent.Parent.FullName), "dd/mmm/yy")
            wksOut.Cells(lngIndex, 3).Value = .Parent.Name
            wksOut.Cells(lngIndex, 4).Value = .Address
            wksOut.Cells(lngIndex, 5).Value = "'" & .Formula
                        
            End With
      Next lngIndex
   End With
End Sub
Sub FindCells(ws As Worksheet, strToFind As String, colOutput As Collection)
   Dim strFirstAddress As String
   Dim rngFound As Range
   With ws.UsedRange
      Set rngFound = .Find(what:=strToFind, lookat:=xlPart, LookIn:=xlFormulas, MatchCase:=False)
      If Not rngFound Is Nothing Then
         strFirstAddress = rngFound.Address
         Do
            colOutput.Add rngFound, ws.Name & "-" & rngFound.Address
            Set rngFound = .FindNext(rngFound)
         Loop While rngFound.Address <> strFirstAddress
      End If
   End With
End Sub

Open in new window

Regards
0
 
LVL 1

Author Closing Comment

by:LMPhillips
ID: 39945423
Thanks, again!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now