opening 30 sheets one by one

kshitij_dch

Active Member
Joined
Apr 1, 2012
Messages
362
Office Version
  1. 365
  2. 2016
  3. 2007
Platform
  1. Windows
hi all i have 30 excel files saved in a folder date wise , like 1-6-2012 , 2-6-2012 , ............30-6-2012 ,


i needs a macro code which will open these 30 files one by one . please help !!!!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
no one by one , 1 st sheet will open after 1 minute it gets closed , than secone sheet will open .
 
Upvote 0
Hi
trry the following macro code
Code:
Sub Thirty files()</SPAN>
Dim z  As Long, e As Long,b as long</SPAN>
Dim f As String, x as string</SPAN>
Sheets("Sheet1").Select</SPAN>
Cells(1, 1) = "=cell(""filename"")"</SPAN>
Cells(1, 2) = "=left(A1,find(""["",A1)-1)"</SPAN>
Cells(2, 1).Select</SPAN>
f = Dir(Cells(1, 2) & "*.xls")</SPAN>
Do While Len(f) > 0</SPAN>
ActiveCell.Formula = f</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
f = Dir()</SPAN>
Loop</SPAN>
z = Cells(Rows.Count, 1).End(xlUp).Row</SPAN>
For e = 2 To z</SPAN>
x =left(cells(e,1),len(cells(e,1))-4)</SPAN>
If Sheets("Sheet1").Cells(e, 1) <> ActiveWorkbook.Name Then</SPAN>
Workbooks.Open filename:=Sheets("sheet1").Cells(e, 1)</SPAN>
Msgbox x</SPAN>
activeworkbook.close true</SPAN>
end if</SPAN>
Next e</SPAN>
MsgBox "complete."
End Sub</SPAN>
Ravi
 
Upvote 0
thanks ravi for the reply , do i need to write file name of all 30 files because all 30 files are saved in a folder with their respective names like 1-06-2012 , 2-6-2012 , 3-6-2012 and so on ????
 
Upvote 0
its not wirking for me type mismatch error is comming , please help !!!! error is comming on line number 8
 
Upvote 0

Forum statistics

Threads
1,203,515
Messages
6,055,850
Members
444,828
Latest member
StaffordStag

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