Changing subdirectories from an array of cel cellsl

  • Thread starter Thread starter Alab
  • Start date Start date
A

Alab

I have named a range of cells in an excel column. In each of the cell
in the column, I have put a different subdirectory name. I would lik
for the macro I am using to pick up the name in the 1st cell & run th
entire macro. At the end of the macro, I would like the name of th
2nd cell to automatically be picked up as the subdirectory to be used
keep running the macro until the last cell in the column is used.

Is there any way to do this
 
Hi Alab

Do you mean this
Cell.value is the folder name
cell.Offset(0, 1) is the filename

A1:A3 = foldernames
B1:B3 = filenames

Sub test()
Dim WB As Workbook
For Each cell In Range("a1:a3")
Set WB = Workbooks.Open("C:\" & cell.Value & "\" & cell.Offset(0, 1) & ".xls")
' do something
WB.Close False
Next
End Sub
 
Alab


sub Test
Dim c As Range
For Each c In Range("nName")
your macro code here or call anothermacro
Next c
end su
 
Back
Top