M
Mark Dullingham
On a worksheet I have the following data
A
1 Name 1
2 Name 2
3 Name 3
etc up to 15
Within the same parent folder I have 15 single page workbooks named the same
as col a ie Name 1, Name 2 etc
I need to import copies of the single sheet workbooks as worksheets in my
main file in the order they appear in COL A
ie sheet1 then Name1, Name2, Name3 etc
So far i have managed to do this with 15 command buttons with the following
code;
Private Sub CommandButton2_Click()
Sheets("Front Sheet").Select
PathName = Range("JA26").Value
Filename = Range("G30").Value
If Filename = "" Then Exit Sub
TabName = Range("I30").Value
If I30 = ("Module 1") Then CommandButton2.Visible = True
ControlFile = ActiveWorkbook.Name
Workbooks.Open Filename:=PathName & Filename
ActiveSheet.Name = TabName
Sheets(TabName).Copy After:=Workbooks(ControlFile).Sheets(1)
Windows(Filename).Activate
ActiveWorkbook.Close SaveChanges:=False
Windows(ControlFile).Activate
Sheets("Front Sheet").Select
End Sub
I would like this to operate from 1 command button.
could some one point me in the right direction please.
Many thanks in advance.
Mark
A
1 Name 1
2 Name 2
3 Name 3
etc up to 15
Within the same parent folder I have 15 single page workbooks named the same
as col a ie Name 1, Name 2 etc
I need to import copies of the single sheet workbooks as worksheets in my
main file in the order they appear in COL A
ie sheet1 then Name1, Name2, Name3 etc
So far i have managed to do this with 15 command buttons with the following
code;
Private Sub CommandButton2_Click()
Sheets("Front Sheet").Select
PathName = Range("JA26").Value
Filename = Range("G30").Value
If Filename = "" Then Exit Sub
TabName = Range("I30").Value
If I30 = ("Module 1") Then CommandButton2.Visible = True
ControlFile = ActiveWorkbook.Name
Workbooks.Open Filename:=PathName & Filename
ActiveSheet.Name = TabName
Sheets(TabName).Copy After:=Workbooks(ControlFile).Sheets(1)
Windows(Filename).Activate
ActiveWorkbook.Close SaveChanges:=False
Windows(ControlFile).Activate
Sheets("Front Sheet").Select
End Sub
I would like this to operate from 1 command button.
could some one point me in the right direction please.
Many thanks in advance.
Mark