0
   Dim Wsh As New IWshRuntimeLibrary.WshShell
   Dim result As WshExec
   Dim fileDate() As String
   Dim path As String
   Dim cmd As String
   path = ThisWorkbook.path & "\Book1"
   cmd = "dir" & path & "/Test"
   Set result = Wsh.Exec("%ComSpec% /c" & cmd)` 
  Do While result.Status = 0
   DoEvents
    Loop
     fileDate = Split(result.StdOut.ReadAll, vbCrLf)

     Dim i As Long
     i = 4
     For Each strData In fileData
     Cells(i, 2).Value = strData
     If Cells(i, 2).Value <> "" Then
     Cells(i, 3).Value = "='" & path & "\[" & strData & "]sheet1'!j4" 
     Cells(i, 4).Value = "='" & path & "\[" & strData & "]sheet1'!C5"
    Cells(i, 6).Value = "='" & path & "\[" & strData & "]sheet1'!J5" 
    Cells(i, 7).Value = "='" & path & "\[" & strData & "]sheet1'!H7"
   End If
   i = i + 1
   Next
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
Learner77
  • 25
  • 6
  • 1
    Please do not post questions which are only a title and a code dump. Edit your post to explain exactly what you're trying to do, and what *specific* problem you're having with your code. https://stackoverflow.com/posts/73949878/edit – Tim Williams Oct 04 '22 at 15:55
  • You might get some inspiration from this, if so give it a vote: https://stackoverflow.com/q/30575923/4961700 – Solar Mike Oct 04 '22 at 18:58

0 Answers0