Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I autocopy text from one textbox to another using VBA in E SunFUd01 Excel Discussion (Misc queries) 0 November 18th 09 06:24 PM
Autocopy formula in tables Stacey Excel Discussion (Misc queries) 1 December 20th 07 10:06 AM
Autocopy formula without VB johnsonlnl29 Excel Discussion (Misc queries) 1 December 15th 06 04:28 PM
Autocopy formula to cells ASU Excel Discussion (Misc queries) 1 September 8th 06 04:43 PM
Autocopy row from several worksheet to another workbook Dave Peterson[_4_] Excel Programming 0 November 9th 04 01:10 AM


All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"