I am writing a macro to perform several actions. In the first action I have one file open and I need to write a code or another macro that will open a second file. The name of the second file will always change. Once the second file is open, I will then continue to the next action. Can you help me with the code? Thank you.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
macro to open a file (Excel 2000)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » macro to open a file (Excel 2000)
- This topic has 39 replies, 6 voices, and was last updated 20 years, 6 months ago.
AuthorTopicWScindypositano
AskWoody LoungerNovember 15, 2004 at 4:01 pm #412275Viewing 3 reply threadsAuthorReplies-
WSsdckapr
AskWoody Lounger -
WScindypositano
AskWoody LoungerNovember 15, 2004 at 5:13 pm #900193The purpose of the overall macro is to copy data from one file (closed) and paste the data into the destination file (open) I need the macro to pause so the user can select the correct file to open. When the file is open, the macro can resume the rest of the actions. The files to open are all identical in layout, etc. Only the numbers are different. Thank you.
-
WScindypositano
AskWoody LoungerNovember 15, 2004 at 5:13 pm #900194The purpose of the overall macro is to copy data from one file (closed) and paste the data into the destination file (open) I need the macro to pause so the user can select the correct file to open. When the file is open, the macro can resume the rest of the actions. The files to open are all identical in layout, etc. Only the numbers are different. Thank you.
-
WSsdckapr
AskWoody LoungerH. Legare Coleman
AskWoody PlusNovember 15, 2004 at 5:19 pm #900197Is something like this what you are looking for?
Option Explicit Sub OpenTargetFile() Dim vTargetFile As Variant Dim wbkTarget As Workbook vTargetFile = Application.GetOpenFilename("Excel Files (*.xls),*.xls, All Files (*.*),*.*", _ 1, "Select Target File") If vTargetFile = False Then Exit Sub End If Set wbkTarget = Workbooks.Open(vTargetFile) End Sub
-
WScindypositano
AskWoody LoungerNovember 15, 2004 at 5:58 pm #900222When I paste your code inside my macro, the code displays all on one line in red. The error message “Compile Error: Syntax Error” is displayed. Here is my current code. I need to open a file the line above this action. Thank you.
Sub CommandButton1_Click()
‘
‘ Sub Interbranch()
‘
‘ InterbranchCopy Macro
‘ Macro recorded 11/09/2004 by bxwallac
‘
Dim DWB As Workbook
Dim DestinationBook As String
Set CWB = ActiveWorkbook
DestinationBook = Application.GetOpenFilename(“All Excel Files,*.xls”)
Workbooks.Open DestinationBook
Set DWB = ActiveWorkbook
CWB.Activate
Sheets(“Inter-Branch Allocation”).Range(“A1216:BI1251”).Copy DWB.Sheets(“Inter-Branch Allocation”).Range(“A1216”)
Sheets(“Detailed Financials”).Range(“AA82:BT82”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA82”)
Sheets(“Detailed Financials”).Range(“AA95:BT95”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA95”)
Sheets(“Monthly Plan Summary”).Range(“Y29:BR29”).Copy DWB.Sheets(“Monthly Plan Summary”).Range(“Y29”)
DWB.ActivateEnd Sub
-
H. Legare Coleman
AskWoody Plus -
WScindypositano
AskWoody LoungerNovember 15, 2004 at 6:30 pm #900232I did as you said. I now get the message, “Invisible inside procedure”. Here is the code.
Sub Macro5()
‘
‘ Macro5 Macro
‘ Macro recorded 11/15/2004 by consultant
‘
Option ExplicitSub OpenTargetFile()
Dim vTargetFile As Variant
Dim wbkTarget As Workbook
vTargetFile = Application.GetOpenFilename(“Excel Files (*.xls),*.xls, All Files (*.*),*.*”, _
1, “Select Target File”)
If vTargetFile = False Then
Exit Sub
End If
Set wbkTarget = Workbooks.Open(vTargetFile)
End Sub -
H. Legare Coleman
AskWoody PlusNovember 15, 2004 at 7:04 pm #900262I believe that the message should have been “Invalid inside procedure” not Invisible.
You pasted my code inside another procedure. That did two things. First, it put the Option Explicit statement inside your procedure, and the Option Explicit statement must be outside all procedures. Move it outside your procedure. BTW, having this statement will require that all variables be declared with a DIM statement. This can catch all kinds of errors that occur by having such errors as variable names spelled differently.
Second, you put my “Sub OpenTargetFile()” inside your procedure. You can’t have a procedure inside a procedure. Therefore, if you want my code inside your procedure, you will need to remove my “Sub OpenTargetFile()” and the “End Sub” that goes with it.
-
-
-
WScindypositano
AskWoody LoungerNovember 15, 2004 at 6:30 pm #900233I did as you said. I now get the message, “Invisible inside procedure”. Here is the code.
Sub Macro5()
‘
‘ Macro5 Macro
‘ Macro recorded 11/15/2004 by consultant
‘
Option ExplicitSub OpenTargetFile()
Dim vTargetFile As Variant
Dim wbkTarget As Workbook
vTargetFile = Application.GetOpenFilename(“Excel Files (*.xls),*.xls, All Files (*.*),*.*”, _
1, “Select Target File”)
If vTargetFile = False Then
Exit Sub
End If
Set wbkTarget = Workbooks.Open(vTargetFile)
End Sub
-
H. Legare Coleman
AskWoody PlusH. Legare Coleman
AskWoody PlusNovember 15, 2004 at 6:21 pm #900228The code below is modified to open a source file. I did not change the code to do anything with that file as I was not clear what you want to do with it.
Sub CommandButton1_Click() ' ' Sub Interbranch() ' ' InterbranchCopy Macro ' Macro recorded 11/09/2004 by bxwallac ' Dim DWB As Workbook Dim CWB As Workbook Dim SWB As Workbook Dim DestinationBook As Variant Dim SourceBook As Variant Set CWB = ActiveWorkbook SourceBook = Application.GetOpenFilename(FileFilter:="All Excel Files,*.xls", Title:="Select Source File") If SourceBook = False Then Exit Sub End If Set SWB = Workbooks.Open(SourceBook) DestinationBook = Application.GetOpenFilename(FileFilter:="All Excel Files,*.xls", Title:="Select Destination File") If DestinationBook = False Then Exit Sub End If Set DWB = Workbooks.Open(DestinationBook) CWB.Activate Sheets("Inter-Branch Allocation").Range("A1216:BI1251").Copy DWB.Sheets("Inter-Branch Allocation").Range("A1216") Sheets("Detailed Financials").Range("AA82:BT82").Copy DWB.Sheets("Detailed Financials").Range("AA82") Sheets("Detailed Financials").Range("AA95:BT95").Copy DWB.Sheets("Detailed Financials").Range("AA95") Sheets("Monthly Plan Summary").Range("Y29:BR29").Copy DWB.Sheets("Monthly Plan Summary").Range("Y29") DWB.Activate End Sub
H. Legare Coleman
AskWoody PlusNovember 15, 2004 at 6:21 pm #900229The code below is modified to open a source file. I did not change the code to do anything with that file as I was not clear what you want to do with it.
Sub CommandButton1_Click() ' ' Sub Interbranch() ' ' InterbranchCopy Macro ' Macro recorded 11/09/2004 by bxwallac ' Dim DWB As Workbook Dim CWB As Workbook Dim SWB As Workbook Dim DestinationBook As Variant Dim SourceBook As Variant Set CWB = ActiveWorkbook SourceBook = Application.GetOpenFilename(FileFilter:="All Excel Files,*.xls", Title:="Select Source File") If SourceBook = False Then Exit Sub End If Set SWB = Workbooks.Open(SourceBook) DestinationBook = Application.GetOpenFilename(FileFilter:="All Excel Files,*.xls", Title:="Select Destination File") If DestinationBook = False Then Exit Sub End If Set DWB = Workbooks.Open(DestinationBook) CWB.Activate Sheets("Inter-Branch Allocation").Range("A1216:BI1251").Copy DWB.Sheets("Inter-Branch Allocation").Range("A1216") Sheets("Detailed Financials").Range("AA82:BT82").Copy DWB.Sheets("Detailed Financials").Range("AA82") Sheets("Detailed Financials").Range("AA95:BT95").Copy DWB.Sheets("Detailed Financials").Range("AA95") Sheets("Monthly Plan Summary").Range("Y29:BR29").Copy DWB.Sheets("Monthly Plan Summary").Range("Y29") DWB.Activate End Sub
-
WScindypositano
AskWoody LoungerNovember 15, 2004 at 7:07 pm #900267I believe this will do it. Thank you. Before I begin the action to copy data, in the newly opened file I want to run an ASAP utility called ‘System, Remove VBA Code’. After that I will then unprotect 3 specific sheets. Last step will to be to run the code to copy. Here’s the problem. Before I began writing the code, the utility ASAP was up on the menu. Now it is gone. How can I keep it on the menu so it can be included in the overall macro? Or do you have code that would remove VBA code from the newly opened file? I was going to place this code after the line ‘End If ‘ and before the line ‘Set DWB = Workbooks.Open(DestinationBook)’. Thank you.
-
H. Legare Coleman
AskWoody Plus -
WScindypositano
AskWoody LoungerNovember 15, 2004 at 7:55 pm #900324ASAP Utilities is a free and easy to use Add-In for MS Excel 97/2000/2002/XP/2003. The utility contains over 300 functions to make your work easier, written by Bastien Mensink. I believe I got this info from one of the Woody posts. Anyway, there is a utility called System, Remove all macros/VBA code from current file. In my macro I first need to open the second file (which you helped me with.) Then, I need to remove all macros/VBA code from the newly opened file. with both files open I then run the macro to copy specific data. If I don’t use this utility, do you have code to remove all macros? BTW, You are brilliant! Thank you.
-
WSsdckapr
AskWoody Lounger -
WScindypositano
AskWoody LoungerNovember 15, 2004 at 8:42 pm #900374Ok, this is the code from Chip that is needed to delete the VBA code in the second file. Can you tell me where to paste it in my macro?
Code –
Sub DeleteAllVBA()Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponentsSet VBComps = ActiveWorkbook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBCompEnd Sub
Where do I paste the above code so it will remove the VBA code from the newly opened file before it starts the copy phase of the macro? Here is my macro:
Sub CommandButton1_Click()
‘
‘ Sub Interbranch()
‘
‘ InterbranchCopy Macro
‘ Macro recorded 11/09/2004 by bxwallac
‘
Dim DWB As Workbook
Dim CWB As Workbook
Dim SWB As Workbook
Dim DestinationBook As Variant
Dim SourceBook As Variant
Set CWB = ActiveWorkbook
SourceBook = Application.GetOpenFilename(FileFilter:=”All Excel Files,*.xls”, Title:=”Select Source File”)
If SourceBook = False Then
Exit Sub
End If
Set SWB = Workbooks.Open(SourceBook)
DestinationBook = Application.GetOpenFilename(FileFilter:=”All Excel Files,*.xls”, Title:=”Select Destination File”)
If DestinationBook = False Then
Exit Sub
End If
Set DWB = Workbooks.Open(DestinationBook)
CWB.Activate
Sheets(“Inter-Branch Allocation”).Range(“A1216:BI1251”).Copy DWB.Sheets(“Inter-Branch Allocation”).Range(“A1216”)
Sheets(“Detailed Financials”).Range(“AA82:BT82”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA82”)
Sheets(“Detailed Financials”).Range(“AA95:BT95”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA95”)
Sheets(“Monthly Plan Summary”).Range(“Y29:BR29”).Copy DWB.Sheets(“Monthly Plan Summary”).Range(“Y29”)
DWB.ActivateEnd Sub
Thank you.
-
WSsdckapr
AskWoody LoungerNovember 15, 2004 at 10:16 pm #900421You can keep the code as a separate routine. Then it would seem that you want to add the line:
DeleteAllVBA
right after the
CWB.Activate
Thus you would activate the “CWB” workbook. Then delete all the code from it. I don’t understand why this is an issue however. Copying the info from CWB to DWB should not be copying over any of the macro code from CWB to DWB.
Or am I missing something?
Steve
-
WScindypositano
AskWoody Lounger -
WScindypositano
AskWoody LoungerNovember 16, 2004 at 4:16 pm #900751Got it. My problem is I want to delete all VBA code from the destination file before the action to copy a range. This doesn’t work. Thank you.
‘ Sub Interbranch()
‘
‘ InterbranchCopy Macro
‘ Macro recorded 11/09/2004 by bxwallac
‘
Dim DWB As Workbook
Dim DestinationBook As String
Set CWB = ActiveWorkbook
DestinationBook = Application.GetOpenFilename(“All Excel Files,*.xls”)
Workbooks.Open DestinationBook
Set DWB = ActiveWorkbook
DeleteAllVBA
Sheets(“Inter-Branch Allocation”).Activate
ActiveSheet.Unprotect
Sheets(“Detailed Financials”).Activate
ActiveSheet.Unprotect
Sheets(“Monthly Plan Summary”).Activate
ActiveSheet.Unprotect
CWB.Activate
Sheets(“Inter-Branch Allocation”).Range(“A1216:BI1251”).Copy DWB.Sheets(“Inter-Branch Allocation”).Range(“A1216”)
Sheets(“Detailed Financials”).Range(“AA82:BT82”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA82”)
Sheets(“Detailed Financials”).Range(“AA95:BT95”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA95”)
Sheets(“Monthly Plan Summary”).Range(“Y29:BR29”).Copy DWB.Sheets(“Monthly Plan Summary”).Range(“Y29″)
DWB.Activate
ActiveWorkbook.ChangeLink Name:=”Interbranch 11-16-2004 Cindy.xls”, NewName:=DWB.FullName, Type:=xlExcelLinksEnd Sub
-
WSsdckapr
AskWoody LoungerNovember 16, 2004 at 5:04 pm #900787Could you be more specific about what doesn’t work?
I created a testfile, added some code and saved it. I uncommented your sub line (I don’t understand why the sub line is commented unless you have another sub line that you didn’t copy) and ran the code. I opened the testfile, and it deleted all the code in the file after it was opened.
Are you getting error messages? Is it deleting code from the wrong workbook? What is the symptom? “Doesn’t work” is pretty vague.
Have you created a reference to the “extensibility library” as described by Chip Pearson on the page I referenced? [fifth paragraph from the top]
Steve
-
WSGoCush
AskWoody LoungerNovember 17, 2004 at 7:43 am #901090I may have misunderstood the original question or the code, but>>>>
I understood the original poster wanted to start with the active workbook (CWB), open a 2nd wbk (DWB), delete all VBA from the DWB, then copy 3-4 ranges from the CWB into the DWB and finally close the DWB and move on to a new DWB where the procedure would be repeated.
The code appears to have a 3rd wbk involved SWB as the source of the ranges to be copied. — No sure if this is what is wanted.
Also, placing the DeleteVBA code after CWB.Activate will delete the code from the original workbook. BE VERY CAREFUL HERE !! ARE YOU SURE THIS IS WHAT YOU WANT?
-
WSGoCush
AskWoody LoungerNovember 17, 2004 at 7:43 am #901091I may have misunderstood the original question or the code, but>>>>
I understood the original poster wanted to start with the active workbook (CWB), open a 2nd wbk (DWB), delete all VBA from the DWB, then copy 3-4 ranges from the CWB into the DWB and finally close the DWB and move on to a new DWB where the procedure would be repeated.
The code appears to have a 3rd wbk involved SWB as the source of the ranges to be copied. — No sure if this is what is wanted.
Also, placing the DeleteVBA code after CWB.Activate will delete the code from the original workbook. BE VERY CAREFUL HERE !! ARE YOU SURE THIS IS WHAT YOU WANT?
-
WSsdckapr
AskWoody LoungerNovember 16, 2004 at 5:04 pm #900788Could you be more specific about what doesn’t work?
I created a testfile, added some code and saved it. I uncommented your sub line (I don’t understand why the sub line is commented unless you have another sub line that you didn’t copy) and ran the code. I opened the testfile, and it deleted all the code in the file after it was opened.
Are you getting error messages? Is it deleting code from the wrong workbook? What is the symptom? “Doesn’t work” is pretty vague.
Have you created a reference to the “extensibility library” as described by Chip Pearson on the page I referenced? [fifth paragraph from the top]
Steve
-
WScindypositano
AskWoody LoungerNovember 16, 2004 at 4:16 pm #900752Got it. My problem is I want to delete all VBA code from the destination file before the action to copy a range. This doesn’t work. Thank you.
‘ Sub Interbranch()
‘
‘ InterbranchCopy Macro
‘ Macro recorded 11/09/2004 by bxwallac
‘
Dim DWB As Workbook
Dim DestinationBook As String
Set CWB = ActiveWorkbook
DestinationBook = Application.GetOpenFilename(“All Excel Files,*.xls”)
Workbooks.Open DestinationBook
Set DWB = ActiveWorkbook
DeleteAllVBA
Sheets(“Inter-Branch Allocation”).Activate
ActiveSheet.Unprotect
Sheets(“Detailed Financials”).Activate
ActiveSheet.Unprotect
Sheets(“Monthly Plan Summary”).Activate
ActiveSheet.Unprotect
CWB.Activate
Sheets(“Inter-Branch Allocation”).Range(“A1216:BI1251”).Copy DWB.Sheets(“Inter-Branch Allocation”).Range(“A1216”)
Sheets(“Detailed Financials”).Range(“AA82:BT82”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA82”)
Sheets(“Detailed Financials”).Range(“AA95:BT95”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA95”)
Sheets(“Monthly Plan Summary”).Range(“Y29:BR29”).Copy DWB.Sheets(“Monthly Plan Summary”).Range(“Y29″)
DWB.Activate
ActiveWorkbook.ChangeLink Name:=”Interbranch 11-16-2004 Cindy.xls”, NewName:=DWB.FullName, Type:=xlExcelLinksEnd Sub
-
WSJohnBF
AskWoody LoungerNovember 16, 2004 at 8:51 pm #900908Cindy, you didn’t ask, but does your co-worker know that you can password protect code so that other users can’t view it? In the VBE, right click the VBAProject, select VBA Project Properties, Protection, check Lock Project for Viewing, and provide a password. Project security can be beaten only by a fairly obscure hacking technique, so for most work I’d trust it.
-
WSJohnBF
AskWoody LoungerNovember 16, 2004 at 8:51 pm #900909Cindy, you didn’t ask, but does your co-worker know that you can password protect code so that other users can’t view it? In the VBE, right click the VBAProject, select VBA Project Properties, Protection, check Lock Project for Viewing, and provide a password. Project security can be beaten only by a fairly obscure hacking technique, so for most work I’d trust it.
-
WScindypositano
AskWoody Lounger -
WSsdckapr
AskWoody LoungerNovember 15, 2004 at 10:16 pm #900422You can keep the code as a separate routine. Then it would seem that you want to add the line:
DeleteAllVBA
right after the
CWB.Activate
Thus you would activate the “CWB” workbook. Then delete all the code from it. I don’t understand why this is an issue however. Copying the info from CWB to DWB should not be copying over any of the macro code from CWB to DWB.
Or am I missing something?
Steve
-
WScindypositano
AskWoody LoungerNovember 15, 2004 at 8:42 pm #900375Ok, this is the code from Chip that is needed to delete the VBA code in the second file. Can you tell me where to paste it in my macro?
Code –
Sub DeleteAllVBA()Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponentsSet VBComps = ActiveWorkbook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBCompEnd Sub
Where do I paste the above code so it will remove the VBA code from the newly opened file before it starts the copy phase of the macro? Here is my macro:
Sub CommandButton1_Click()
‘
‘ Sub Interbranch()
‘
‘ InterbranchCopy Macro
‘ Macro recorded 11/09/2004 by bxwallac
‘
Dim DWB As Workbook
Dim CWB As Workbook
Dim SWB As Workbook
Dim DestinationBook As Variant
Dim SourceBook As Variant
Set CWB = ActiveWorkbook
SourceBook = Application.GetOpenFilename(FileFilter:=”All Excel Files,*.xls”, Title:=”Select Source File”)
If SourceBook = False Then
Exit Sub
End If
Set SWB = Workbooks.Open(SourceBook)
DestinationBook = Application.GetOpenFilename(FileFilter:=”All Excel Files,*.xls”, Title:=”Select Destination File”)
If DestinationBook = False Then
Exit Sub
End If
Set DWB = Workbooks.Open(DestinationBook)
CWB.Activate
Sheets(“Inter-Branch Allocation”).Range(“A1216:BI1251”).Copy DWB.Sheets(“Inter-Branch Allocation”).Range(“A1216”)
Sheets(“Detailed Financials”).Range(“AA82:BT82”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA82”)
Sheets(“Detailed Financials”).Range(“AA95:BT95”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA95”)
Sheets(“Monthly Plan Summary”).Range(“Y29:BR29”).Copy DWB.Sheets(“Monthly Plan Summary”).Range(“Y29”)
DWB.ActivateEnd Sub
Thank you.
-
WSsdckapr
AskWoody Lounger -
WSrory
AskWoody LoungerNovember 17, 2004 at 12:09 pm #901200Cindy,
Just for future reference, if you want to call any ASAP code from your own code, you can set a reference to the ASAP Utilities add-in (via Tools-References) and then call the procedure as normal – in your current example that would be something like:DWB.Activate Call ASAPUtilities.RemoveAllVBA
-
WSrory
AskWoody LoungerNovember 17, 2004 at 12:09 pm #901201Cindy,
Just for future reference, if you want to call any ASAP code from your own code, you can set a reference to the ASAP Utilities add-in (via Tools-References) and then call the procedure as normal – in your current example that would be something like:DWB.Activate Call ASAPUtilities.RemoveAllVBA
-
WScindypositano
AskWoody LoungerNovember 15, 2004 at 7:55 pm #900325ASAP Utilities is a free and easy to use Add-In for MS Excel 97/2000/2002/XP/2003. The utility contains over 300 functions to make your work easier, written by Bastien Mensink. I believe I got this info from one of the Woody posts. Anyway, there is a utility called System, Remove all macros/VBA code from current file. In my macro I first need to open the second file (which you helped me with.) Then, I need to remove all macros/VBA code from the newly opened file. with both files open I then run the macro to copy specific data. If I don’t use this utility, do you have code to remove all macros? BTW, You are brilliant! Thank you.
-
H. Legare Coleman
AskWoody Plus
-
WScindypositano
AskWoody LoungerNovember 15, 2004 at 7:07 pm #900268I believe this will do it. Thank you. Before I begin the action to copy data, in the newly opened file I want to run an ASAP utility called ‘System, Remove VBA Code’. After that I will then unprotect 3 specific sheets. Last step will to be to run the code to copy. Here’s the problem. Before I began writing the code, the utility ASAP was up on the menu. Now it is gone. How can I keep it on the menu so it can be included in the overall macro? Or do you have code that would remove VBA code from the newly opened file? I was going to place this code after the line ‘End If ‘ and before the line ‘Set DWB = Workbooks.Open(DestinationBook)’. Thank you.
WScindypositano
AskWoody LoungerNovember 15, 2004 at 5:58 pm #900223When I paste your code inside my macro, the code displays all on one line in red. The error message “Compile Error: Syntax Error” is displayed. Here is my current code. I need to open a file the line above this action. Thank you.
Sub CommandButton1_Click()
‘
‘ Sub Interbranch()
‘
‘ InterbranchCopy Macro
‘ Macro recorded 11/09/2004 by bxwallac
‘
Dim DWB As Workbook
Dim DestinationBook As String
Set CWB = ActiveWorkbook
DestinationBook = Application.GetOpenFilename(“All Excel Files,*.xls”)
Workbooks.Open DestinationBook
Set DWB = ActiveWorkbook
CWB.Activate
Sheets(“Inter-Branch Allocation”).Range(“A1216:BI1251”).Copy DWB.Sheets(“Inter-Branch Allocation”).Range(“A1216”)
Sheets(“Detailed Financials”).Range(“AA82:BT82”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA82”)
Sheets(“Detailed Financials”).Range(“AA95:BT95”).Copy DWB.Sheets(“Detailed Financials”).Range(“AA95”)
Sheets(“Monthly Plan Summary”).Range(“Y29:BR29”).Copy DWB.Sheets(“Monthly Plan Summary”).Range(“Y29”)
DWB.ActivateEnd Sub
H. Legare Coleman
AskWoody PlusNovember 15, 2004 at 5:19 pm #900198Is something like this what you are looking for?
Option Explicit Sub OpenTargetFile() Dim vTargetFile As Variant Dim wbkTarget As Workbook vTargetFile = Application.GetOpenFilename("Excel Files (*.xls),*.xls, All Files (*.*),*.*", _ 1, "Select Target File") If vTargetFile = False Then Exit Sub End If Set wbkTarget = Workbooks.Open(vTargetFile) End Sub
Viewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
What goes on inside an LLM
by
Michael Covington
1 hour, 11 minutes ago -
The risk of remote access
by
Susan Bradley
1 hour, 11 minutes ago -
The cruelest month for many Office users
by
Peter Deegan
1 hour, 12 minutes ago -
Tracking protection and trade-offs in Edge
by
Mary Branscombe
1 hour, 14 minutes ago -
Supreme Court grants DOGE access to confidential Social Security records
by
Alex5723
1 hour, 15 minutes ago -
EaseUS Partition Master free 19.6
by
Alex5723
2 hours, 13 minutes ago -
Microsoft : Edge is better than Chrome
by
Alex5723
14 hours, 32 minutes ago -
The EU launched DNS4EU
by
Alex5723
1 day, 3 hours ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
17 hours, 34 minutes ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
1 day, 8 hours ago -
Set default size for pasted photo to word
by
Cyn
1 day, 14 hours ago -
Dedoimedo tries 24H2…
by
Cybertooth
1 day, 2 hours ago -
Windows 11 Insider Preview build 27871 released to Canary
by
joep517
2 days, 13 hours ago -
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
6 hours, 27 minutes ago -
Small desktops
by
Susan Bradley
5 hours, 33 minutes ago -
Totally disable Bitlocker
by
CWBillow
1 day, 7 hours ago -
Phishers extract Millions from HMRC accounts..
by
Microfix
2 days, 11 hours ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
3 days, 17 hours ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
1 day, 12 hours ago -
Mystical Desktop
by
CWBillow
3 days, 20 hours ago -
Meta and Yandex secretly tracked billions of Android users
by
Alex5723
3 days, 2 hours ago -
MS-DEFCON 2: Do you need that update?
by
Susan Bradley
13 hours, 31 minutes ago -
CD/DVD drive is no longer recognized
by
WSCape Sand
4 days, 12 hours ago -
Windows 11 24H2 Default Apps stuck on Edge and Adobe Photoshop
by
MikeBravo
4 days, 14 hours ago -
North Face and Cartier customer data stolen in cyber attacks
by
Alex5723
4 days, 13 hours ago -
What is wrong with simple approach?
by
WSSpoke36
2 days, 11 hours ago -
Microsoft-Backed Builder.ai Set for Bankruptcy After Cash Seized
by
Alex5723
5 days ago -
Location, location, location
by
Susan Bradley
3 days, 14 hours ago -
Cannot get a task to run a restore point
by
CWBillow
5 days, 1 hour ago -
Frustrating search behavior with Outlook
by
MrJimPhelps
4 days, 16 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.