Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Macro to Copy / paste from 1 workbook to another

I'm using a macro to copy from one workbook to another in the same instance
of Excel. The macro successfully copies the data to the clipboard but does
not proceed to paste it in the new workbook. No error screen pops up it just
doesn't paste. Your help is appreciated. Here is my current macro code:

Sub CopyPasteToNCTthree()
'
' CopyPasteToNCTthree Macro
' Macro recorded 4/20/2009 by _
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Sheets("Installer").Select
Range("O2:O8").Select
Selection.Copy
Workbooks.Open Filename:="C:\Zip Documents\Customers\New Customer
Test.xls"
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("O2:O8").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O8").Select
End Sub
--
David P.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Macro to Copy / paste from 1 workbook to another

Hi David

Not have time to test your code now but see if this is working for you
http://www.rondebruin.nl/copy1.htm

See the example
What if the Database sheet is in another workbook

You can use most of the code in the example

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
I'm using a macro to copy from one workbook to another in the same instance
of Excel. The macro successfully copies the data to the clipboard but does
not proceed to paste it in the new workbook. No error screen pops up it just
doesn't paste. Your help is appreciated. Here is my current macro code:

Sub CopyPasteToNCTthree()
'
' CopyPasteToNCTthree Macro
' Macro recorded 4/20/2009 by _
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Sheets("Installer").Select
Range("O2:O8").Select
Selection.Copy
Workbooks.Open Filename:="C:\Zip Documents\Customers\New Customer
Test.xls"
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("O2:O8").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O8").Select
End Sub
--
David P.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Macro to Copy / paste from 1 workbook to another

Thanks Ron. It's getting stuck at bIsBookOpen_RB. I have changed all the file
& sheet names. When you say "database workbook" do you just mean new
workbook? Should I alter the Lr = LastRow (DestSh) and Set DestRange... part?
--
David P.


"Ron de Bruin" wrote:

Hi David

Not have time to test your code now but see if this is working for you
http://www.rondebruin.nl/copy1.htm

See the example
What if the Database sheet is in another workbook

You can use most of the code in the example

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
I'm using a macro to copy from one workbook to another in the same instance
of Excel. The macro successfully copies the data to the clipboard but does
not proceed to paste it in the new workbook. No error screen pops up it just
doesn't paste. Your help is appreciated. Here is my current macro code:

Sub CopyPasteToNCTthree()
'
' CopyPasteToNCTthree Macro
' Macro recorded 4/20/2009 by _
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Sheets("Installer").Select
Range("O2:O8").Select
Selection.Copy
Workbooks.Open Filename:="C:\Zip Documents\Customers\New Customer
Test.xls"
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("O2:O8").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O8").Select
End Sub
--
David P.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Macro to Copy / paste from 1 workbook to another

this is what I've done so far and initially gets stuck on bIsBookOpen:

Sub CopyToAnotherWorkbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If bIsBookOpen_RB("New Customer Test.xls") Then
Set DestWB = Workbooks("New Customer Test.xls")
Else
Set DestWB = Workbooks.Open("J:\Zip Documents\Customers\New Customer
Test.xls")
End If
Set SourceRange = ThisWorkbook.Sheets("Installer").Range("O2:O8")
Set DestSh = DestWB.Worksheets("Installer")
Lr = LastRow(DestSh)
Set DestRange = DestSh.Range("A" & Lr + 1)
With SourceRange
Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value
End Sub

--
David P.


"Ron de Bruin" wrote:

Hi David

Not have time to test your code now but see if this is working for you
http://www.rondebruin.nl/copy1.htm

See the example
What if the Database sheet is in another workbook

You can use most of the code in the example

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
I'm using a macro to copy from one workbook to another in the same instance
of Excel. The macro successfully copies the data to the clipboard but does
not proceed to paste it in the new workbook. No error screen pops up it just
doesn't paste. Your help is appreciated. Here is my current macro code:

Sub CopyPasteToNCTthree()
'
' CopyPasteToNCTthree Macro
' Macro recorded 4/20/2009 by _
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Sheets("Installer").Select
Range("O2:O8").Select
Selection.Copy
Workbooks.Open Filename:="C:\Zip Documents\Customers\New Customer
Test.xls"
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("O2:O8").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O8").Select
End Sub
--
David P.


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Macro to Copy / paste from 1 workbook to another

You find the two functions below the macro
This example will copy the data each time below the other data

You can remove
Lr = LastRow(DestSh)

And use this if you want a fixed range (you not need the lastrow function then)
Set DestRange = DestSh.Range("A10" )

Bedtime for me so goodnight


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
this is what I've done so far and initially gets stuck on bIsBookOpen:

Sub CopyToAnotherWorkbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If bIsBookOpen_RB("New Customer Test.xls") Then
Set DestWB = Workbooks("New Customer Test.xls")
Else
Set DestWB = Workbooks.Open("J:\Zip Documents\Customers\New Customer
Test.xls")
End If
Set SourceRange = ThisWorkbook.Sheets("Installer").Range("O2:O8")
Set DestSh = DestWB.Worksheets("Installer")
Lr = LastRow(DestSh)
Set DestRange = DestSh.Range("A" & Lr + 1)
With SourceRange
Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value
End Sub

--
David P.


"Ron de Bruin" wrote:

Hi David

Not have time to test your code now but see if this is working for you
http://www.rondebruin.nl/copy1.htm

See the example
What if the Database sheet is in another workbook

You can use most of the code in the example

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
I'm using a macro to copy from one workbook to another in the same instance
of Excel. The macro successfully copies the data to the clipboard but does
not proceed to paste it in the new workbook. No error screen pops up it just
doesn't paste. Your help is appreciated. Here is my current macro code:

Sub CopyPasteToNCTthree()
'
' CopyPasteToNCTthree Macro
' Macro recorded 4/20/2009 by _
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Sheets("Installer").Select
Range("O2:O8").Select
Selection.Copy
Workbooks.Open Filename:="C:\Zip Documents\Customers\New Customer
Test.xls"
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("O2:O8").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O8").Select
End Sub
--
David P.




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Macro to Copy / paste from 1 workbook to another

I was using a shorcut key that's why it wasn't working. Thanks.
--
David P.


"Ron de Bruin" wrote:

You find the two functions below the macro
This example will copy the data each time below the other data

You can remove
Lr = LastRow(DestSh)

And use this if you want a fixed range (you not need the lastrow function then)
Set DestRange = DestSh.Range("A10" )

Bedtime for me so goodnight


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
this is what I've done so far and initially gets stuck on bIsBookOpen:

Sub CopyToAnotherWorkbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If bIsBookOpen_RB("New Customer Test.xls") Then
Set DestWB = Workbooks("New Customer Test.xls")
Else
Set DestWB = Workbooks.Open("J:\Zip Documents\Customers\New Customer
Test.xls")
End If
Set SourceRange = ThisWorkbook.Sheets("Installer").Range("O2:O8")
Set DestSh = DestWB.Worksheets("Installer")
Lr = LastRow(DestSh)
Set DestRange = DestSh.Range("A" & Lr + 1)
With SourceRange
Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value
End Sub

--
David P.


"Ron de Bruin" wrote:

Hi David

Not have time to test your code now but see if this is working for you
http://www.rondebruin.nl/copy1.htm

See the example
What if the Database sheet is in another workbook

You can use most of the code in the example

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
I'm using a macro to copy from one workbook to another in the same instance
of Excel. The macro successfully copies the data to the clipboard but does
not proceed to paste it in the new workbook. No error screen pops up it just
doesn't paste. Your help is appreciated. Here is my current macro code:

Sub CopyPasteToNCTthree()
'
' CopyPasteToNCTthree Macro
' Macro recorded 4/20/2009 by _
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Sheets("Installer").Select
Range("O2:O8").Select
Selection.Copy
Workbooks.Open Filename:="C:\Zip Documents\Customers\New Customer
Test.xls"
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("O2:O8").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O8").Select
End Sub
--
David P.


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Macro to Copy / paste from 1 workbook to another

I was using a keyboard shortcut. That was the problem with my original code
not working. Many thanks.
--
David P.


"Ron de Bruin" wrote:

You find the two functions below the macro
This example will copy the data each time below the other data

You can remove
Lr = LastRow(DestSh)

And use this if you want a fixed range (you not need the lastrow function then)
Set DestRange = DestSh.Range("A10" )

Bedtime for me so goodnight


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
this is what I've done so far and initially gets stuck on bIsBookOpen:

Sub CopyToAnotherWorkbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If bIsBookOpen_RB("New Customer Test.xls") Then
Set DestWB = Workbooks("New Customer Test.xls")
Else
Set DestWB = Workbooks.Open("J:\Zip Documents\Customers\New Customer
Test.xls")
End If
Set SourceRange = ThisWorkbook.Sheets("Installer").Range("O2:O8")
Set DestSh = DestWB.Worksheets("Installer")
Lr = LastRow(DestSh)
Set DestRange = DestSh.Range("A" & Lr + 1)
With SourceRange
Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value
End Sub

--
David P.


"Ron de Bruin" wrote:

Hi David

Not have time to test your code now but see if this is working for you
http://www.rondebruin.nl/copy1.htm

See the example
What if the Database sheet is in another workbook

You can use most of the code in the example

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"David P." wrote in message ...
I'm using a macro to copy from one workbook to another in the same instance
of Excel. The macro successfully copies the data to the clipboard but does
not proceed to paste it in the new workbook. No error screen pops up it just
doesn't paste. Your help is appreciated. Here is my current macro code:

Sub CopyPasteToNCTthree()
'
' CopyPasteToNCTthree Macro
' Macro recorded 4/20/2009 by _
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Sheets("Installer").Select
Range("O2:O8").Select
Selection.Copy
Workbooks.Open Filename:="C:\Zip Documents\Customers\New Customer
Test.xls"
Range("O2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("O2:O8").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O8").Select
End Sub
--
David P.


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
Copy workbook to 2nd workbook paste is greyed out elmer Excel Worksheet Functions 2 January 28th 09 06:06 PM
macro to copy and paste into another workbook spirosu Excel Discussion (Misc queries) 1 March 15th 06 06:26 PM
Macro to open workbook and copy and paste values in to orig workbo Dena X Excel Worksheet Functions 1 December 15th 05 11:13 PM
copy and paste using code from workbook to workbook bigdaddy3 Excel Discussion (Misc queries) 2 September 14th 05 11:06 AM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM


All times are GMT +1. The time now is 01:19 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"