Solved

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

Posted on 2014-03-20
2
117 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 49

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

809 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