Results 1 to 5 of 5

Thread: Vba - Check String/Text From Multiple Workbook Without Opening All Files

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Its never late here, Pascal, - furthering the subject at any time is what we’re about,
    I actually wanted to try at a solution like yours, but I am not so well clued up generally on formulas, and I am not so sure which ones work on closed workbooks. Some don’t for some reason I don’t know yet.
    But I expected a solution like you did might be a bit more efficient as you just use a temporary cell rather than a temporary range as mine did.
    (You got a small typo I think, .Formula2R1C1 should be .FormulaR1C1)

    ( I always use .Value when I put a formula into a cell with coding. Its just a personal preference based on a (very likely dodgy) “Alan theory” that .Value applied to a cell in coding is seen as if you type stuff in manually in the spreadsheet, and the thing telling Excel it's a formula is the _"="_, just as it would be if you typed it in manually in the spreadsheet
    .FormulaR1C1 is probably the more better and correct way, but I like to indulge in my fantasy theories,
    )


    Alan

    Code:
    '  Pascal    https://excelfox.com/forum/showthread.php/2780-Vba-Check-String-Text-From-Multiple-Workbook-Without-Opening-All-Files?p=16356&viewfull=1#post16356
    Sub blah()
    Dim Fs As Object, Pth As String, F As Variant, Wb As Object, Msg As String
    Set Fs = CreateObject("Scripting.FileSystemObject")
     Let Pth = ThisWorkbook.Path '"D:\Target"
    Set F = Fs.GetFolder(Pth)
        For Each Wb In F.Files
          If InStr(1, Wb.Type, "Excel", vbTextCompare) > 0 Then
            With Range("C4") 'use a cell where it doesn't matter
             '.FormulaR1C1 = "=SUMPRODUCT(--ISTEXT('" & Pth & "\[" & Wb.Name & "]Sheet1'!R6C1:R11C15))"
            .Value = "=SUMPRODUCT(--ISTEXT('" & Pth & "\[" & Wb.Name & "]Sheet1'!R6C1:R11C15))"
                If .Value > 0 Then If Len(Msg) = 0 Then Msg = Wb.Name Else Msg = Msg & vbLf & Wb.Name
             .Clear
            End With
          End If
        Next Wb
        If Len(Msg) > 0 Then
          MsgBox "Workbooks containing any string in range B6:O11 are:" & vbLf & Msg
        Else
          MsgBox "None found"
        End If
    End Sub
    Last edited by DocAElstein; 01-30-2022 at 08:43 PM.

Similar Threads

  1. Replies: 116
    Last Post: 02-23-2025, 12:13 AM
  2. Replies: 101
    Last Post: 06-11-2020, 02:01 PM
  3. Replies: 2
    Last Post: 04-14-2013, 09:15 PM
  4. Replies: 2
    Last Post: 01-29-2013, 02:45 PM
  5. Replies: 2
    Last Post: 09-24-2012, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •