VBA code, I have seen this before but I need help open workbook and get cell value close workbook

caddman2001

New Member
Joined
Jul 27, 2013
Messages
4
I am using Excel 2010, I have the file path + filename Column A (all excel files), file path Column B, file name Column C.

I need to paste multiple cell values from the list in column A into Columns D, E, F, G etc.

The VBA code for the file list is from this GREAT site:

Let strArr(i, 1) = strDir & strName
Let strName = Dir$()
Loop
Set fso = CreateObject("Scripting.FileSystemObject")
Call recurseSubFolders(fso.GetFolder(strDir), strArr(), i)
Set fso = Nothing
If i > 0 Then
Range("A1").Resize(i).Value = strArr
End If


' Next, loop through all found files
' and break into path and filename
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To FinalRow
ThisEntry = Cells(i, 1)
For j = Len(ThisEntry) To 1 Step -1
If Mid(ThisEntry, j, 1) = Application.PathSeparator Then
Cells(i, 2) = Left(ThisEntry, j)
Cells(i, 3) = Mid(ThisEntry, j + 1)
Exit For
End If
Next j
Next i


End Sub




Private Sub recurseSubFolders(ByRef Folder As Object, _
ByRef strArr() As String, _
ByRef i As Long)
Dim SubFolder As Object
Dim strName As String
For Each SubFolder In Folder.SubFolders
Let strName = Dir$(SubFolder.path & "\*.xls*")
Do While strName <> vbNullString
Let i = i + 1
Let strArr(i, 1) = SubFolder.path & strName
Let strName = Dir$()
Loop
Call recurseSubFolders(SubFolder, strArr(), i)
Next
End Sub

I would like to keep this as one macro and run a second macro to retrieve the values.

Thanks in advance!

Caddman2001
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I have also tried imputing the sheet 1 A7 into a formula in A1 + B1 (A1= C:\Users\BooGotShot\Desktop\fdf\10_(SEP) Datasheet For Expansion Joint.xls) + B1='C:\Users\BooGotShot\Desktop\fdf\SPCA0021 Item 5 and 6\[SPCA-0021 EJMA9th Design with dual ply.xls]Sheet1'!$A$7.

This only gives an error as the workbook has not been opened.

The Workbooks are calculations for an engineering program that are filled in by numerous people and I am after input and results from Sheet1. All the excel files are different names but all are formatted the same. The information is on Sheet1 and the same cells across the directories and subdirectories. This is why I used the fileget to have the path and file name.

Again all help is appreciated!

If I am not explaining my need or what I currently have, please tell me the information I need to post and will do so ASAP as I am under the gun to go through lots of files and need to finish by Monday....

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top