Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Autocopy between 2 workbooks
Hi all,
I would like to create code to accomplish the following but as I know very little any help would be appreciated: I have 2 workbooks of which the names could differ from time to time I would like to create a procedure to copy say range A1:H13 from workbook 1 to the same range in workbook 2. Which commands would I use to switch between the 2 workbooks and how will I identify them so that I paste to the correct 1? TIA FD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Autocopy between 2 workbooks
Saved from a previous post:
If you want to prompt the user, you could... Option Explicit Sub testme() Dim rngF As Range Dim rngT As Range Set rngF = Nothing On Error Resume Next Set rngF = Application.InputBox(Prompt:="Select the range", _ Default:=Selection.Areas(1).Address(external:=True ), _ Type:=8).Areas(1) On Error GoTo 0 If rngF Is Nothing Then MsgBox "Try later" Exit Sub End If Set rngT = Nothing On Error Resume Next Set rngT = Application.InputBox(Prompt:="Select the range", Type:=8) _ .Cells(1) On Error GoTo 0 If rngT Is Nothing Then MsgBox "Try later" Exit Sub End If rngF.Copy _ Destination:=rngT Application.CutCopyMode = False End Sub You can swap between workbooks by clicking on Window and choosing the workbook from there. If you always want to paste into the same address, you could change this line: rngF.Copy _ Destination:=rngT to rngF.Copy _ Destination:=rngT.parent.range(rngf.address) But you'd still need some way to get that other worksheet. If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm FrigidDigit wrote: Hi all, I would like to create code to accomplish the following but as I know very little any help would be appreciated: I have 2 workbooks of which the names could differ from time to time I would like to create a procedure to copy say range A1:H13 from workbook 1 to the same range in workbook 2. Which commands would I use to switch between the 2 workbooks and how will I identify them so that I paste to the correct 1? TIA FD -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Autocopy between 2 workbooks
Dave thank you SO MUCH man!
Appreciate the help. "Dave Peterson" wrote in message ... Saved from a previous post: If you want to prompt the user, you could... Option Explicit Sub testme() Dim rngF As Range Dim rngT As Range Set rngF = Nothing On Error Resume Next Set rngF = Application.InputBox(Prompt:="Select the range", _ Default:=Selection.Areas(1).Address(external:=True ), _ Type:=8).Areas(1) On Error GoTo 0 If rngF Is Nothing Then MsgBox "Try later" Exit Sub End If Set rngT = Nothing On Error Resume Next Set rngT = Application.InputBox(Prompt:="Select the range", Type:=8) _ .Cells(1) On Error GoTo 0 If rngT Is Nothing Then MsgBox "Try later" Exit Sub End If rngF.Copy _ Destination:=rngT Application.CutCopyMode = False End Sub You can swap between workbooks by clicking on Window and choosing the workbook from there. If you always want to paste into the same address, you could change this line: rngF.Copy _ Destination:=rngT to rngF.Copy _ Destination:=rngT.parent.range(rngf.address) But you'd still need some way to get that other worksheet. If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm FrigidDigit wrote: Hi all, I would like to create code to accomplish the following but as I know very little any help would be appreciated: I have 2 workbooks of which the names could differ from time to time I would like to create a procedure to copy say range A1:H13 from workbook 1 to the same range in workbook 2. Which commands would I use to switch between the 2 workbooks and how will I identify them so that I paste to the correct 1? TIA FD -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I autocopy text from one textbox to another using VBA in E | Excel Discussion (Misc queries) | |||
Autocopy formula in tables | Excel Discussion (Misc queries) | |||
Autocopy formula without VB | Excel Discussion (Misc queries) | |||
Autocopy formula to cells | Excel Discussion (Misc queries) | |||
Autocopy row from several worksheet to another workbook | Excel Programming |