consolidated sheet

manojxls

New Member
Joined
Dec 21, 2017
Messages
24
Office Version
  1. 365
  2. 2007
  3. 2003 or older
Platform
  1. Windows
Hi, I want to consolidated sheet from 10 different workbook to single sheet in same folder.

VBA code should like, first check that file exists or not if exit than run code if file not exist then exit sub or loop.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
HI James, thanks for reply but due to privacy issue i cannot download the above file. but need vba code i tried below but it became loop or i making something wrong as all excel freeze. below is code.

Sub book1()
myfile = "C:\Users\Manoj\Documents\New folder (2)\test1\1.xlsx"
Workbooks.Open Filename:="C:\Users\Manoj\Documents\New folder (2)\1.xlsx"

If Dir(myfile) <> "" Then
MsgBox "opened 1"
MsgBox "opened ok1"
Call book2 'MsgBox "exit"
Else
Call book2
End If
Workbooks("1.xlsx").Close

End Sub


Sub book2()
myfile = "C:\Users\Manoj\Documents\New folder (2)\test1\2.xlsx"
Workbooks.Open Filename:="C:\Users\Manoj\Documents\New folder (2)\2.xlsx"

If Dir(myfile) <> "" Then
MsgBox "opened 2"
MsgBox "opened ok2"
Call book3 'MsgBox "exit"
Else
Call book3
End If
Workbooks("2.xlsx").Close


End Sub


Sub book3()
myfile = "C:\Users\Manoj\Documents\New folder (2)\test1\3.xlsx"
Workbooks.Open Filename:="C:\Users\Manoj\Documents\New folder (2)\3.xlsx"

If Dir(myfile) <> "" Then
MsgBox "opened 3"
MsgBox "opened ok3"
Call book4 'MsgBox "exit"
Else
Call book4
End If
Workbooks("3.xlsx").Close
End Sub


Sub book4()
myfile = "C:\Users\Manoj\Documents\New folder (2)\test1\4.xlsx"
Workbooks.Open Filename:="C:\Users\Manoj\Documents\New folder (2)\4.xlsx"

If Dir(myfile) <> "" Then
MsgBox "opened 4"
MsgBox "opened ok4"
'Call book4 'MsgBox "exit"
Else
'Call book4
End If
Workbooks("4.xlsx").Close
End Sub
 
Upvote 0
Hello,

If you are dealing with 10 workbooks to consolidate ... you must have an 11th file : the Master File ... the one which will hold the macro which will handle everything ...

If this your structure ?
 
Upvote 0
VBA code should like, first check that file exists or not if exit than run code if file not exist then exit sub or loop master file will 11th file
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,229
Members
448,879
Latest member
VanGirl

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