Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default PasteSpecial issue

I use the code to copy data from a temporary worksheet into a production
worksheet and it works fine with the "ActiveSheet.Paste" line near the
bottom. The problem is that I need to use PasteSpecial instead . I tried
using " ActiveSheet.PasteSpecial Paste:=xlPasteValues" but I get an
"Application-defined or object-defined error"


Public Sub CopyPasteToday()

Dim Targetbook As Workbook

'The workbook that will receive the data
Set Targetbook = ActiveWorkbook

Module3.Disable_Events

Range("A" & ActiveCell.Row).Select

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveCell.Offset(2, 0).EntireRow.Columns("A").Select

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Workbooks.Open Filename:="P:\NoShow\tempnoshow.xls"
Sheets("Sheet1").Select

With Workbooks("TempNoShow.xls").Worksheets("Sheet1")
Columns("E:E").Select
Selection.NumberFormat = "mm/dd/yyyy"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A2:E35").Select
Selection.Copy
Windows("No_Show_2008.xls").Activate
ActiveWindow.WindowState = xlMaximized
ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select


ActiveSheet.Paste


End With

Windows("TempNoShow.xls").Close

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveWorkbook.Activate

Application.WindowState = xlMaximized

Module3.Enable_Events

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default PasteSpecial issue

hi
you could change Activesheet.paste to
selection.pastespecial xlpastevalues
but what i would do is instead of these lines.....

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste

I would change to.....

Range("C65000").end(xlup).offset(1,-1). _
Pastespecial xlpastevalues

one line...wrapped. this would eliminate the need for selecting.

Regards
FSt1

"Patrick C. Simonds" wrote:

I use the code to copy data from a temporary worksheet into a production
worksheet and it works fine with the "ActiveSheet.Paste" line near the
bottom. The problem is that I need to use PasteSpecial instead . I tried
using " ActiveSheet.PasteSpecial Paste:=xlPasteValues" but I get an
"Application-defined or object-defined error"


Public Sub CopyPasteToday()

Dim Targetbook As Workbook

'The workbook that will receive the data
Set Targetbook = ActiveWorkbook

Module3.Disable_Events

Range("A" & ActiveCell.Row).Select

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveCell.Offset(2, 0).EntireRow.Columns("A").Select

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Workbooks.Open Filename:="P:\NoShow\tempnoshow.xls"
Sheets("Sheet1").Select

With Workbooks("TempNoShow.xls").Worksheets("Sheet1")
Columns("E:E").Select
Selection.NumberFormat = "mm/dd/yyyy"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A2:E35").Select
Selection.Copy
Windows("No_Show_2008.xls").Activate
ActiveWindow.WindowState = xlMaximized
ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select


ActiveSheet.Paste


End With

Windows("TempNoShow.xls").Close

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveWorkbook.Activate

Application.WindowState = xlMaximized

Module3.Enable_Events

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default PasteSpecial issue

Thank you, that did the trick.

"FSt1" wrote in message
...
hi
you could change Activesheet.paste to
selection.pastespecial xlpastevalues
but what i would do is instead of these lines.....

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste

I would change to.....

Range("C65000").end(xlup).offset(1,-1). _
Pastespecial xlpastevalues

one line...wrapped. this would eliminate the need for selecting.

Regards
FSt1

"Patrick C. Simonds" wrote:

I use the code to copy data from a temporary worksheet into a production
worksheet and it works fine with the "ActiveSheet.Paste" line near the
bottom. The problem is that I need to use PasteSpecial instead . I tried
using " ActiveSheet.PasteSpecial Paste:=xlPasteValues" but I get an
"Application-defined or object-defined error"


Public Sub CopyPasteToday()

Dim Targetbook As Workbook

'The workbook that will receive the data
Set Targetbook = ActiveWorkbook

Module3.Disable_Events

Range("A" & ActiveCell.Row).Select

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveCell.Offset(2, 0).EntireRow.Columns("A").Select

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Workbooks.Open Filename:="P:\NoShow\tempnoshow.xls"
Sheets("Sheet1").Select

With Workbooks("TempNoShow.xls").Worksheets("Sheet1")
Columns("E:E").Select
Selection.NumberFormat = "mm/dd/yyyy"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A2:E35").Select
Selection.Copy
Windows("No_Show_2008.xls").Activate
ActiveWindow.WindowState = xlMaximized
ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select


ActiveSheet.Paste


End With

Windows("TempNoShow.xls").Close

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveWorkbook.Activate

Application.WindowState = xlMaximized

Module3.Enable_Events

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default PasteSpecial issue

you're welcome
Regards
FSt1

"Patrick C. Simonds" wrote:

Thank you, that did the trick.

"FSt1" wrote in message
...
hi
you could change Activesheet.paste to
selection.pastespecial xlpastevalues
but what i would do is instead of these lines.....

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste

I would change to.....

Range("C65000").end(xlup).offset(1,-1). _
Pastespecial xlpastevalues

one line...wrapped. this would eliminate the need for selecting.

Regards
FSt1

"Patrick C. Simonds" wrote:

I use the code to copy data from a temporary worksheet into a production
worksheet and it works fine with the "ActiveSheet.Paste" line near the
bottom. The problem is that I need to use PasteSpecial instead . I tried
using " ActiveSheet.PasteSpecial Paste:=xlPasteValues" but I get an
"Application-defined or object-defined error"


Public Sub CopyPasteToday()

Dim Targetbook As Workbook

'The workbook that will receive the data
Set Targetbook = ActiveWorkbook

Module3.Disable_Events

Range("A" & ActiveCell.Row).Select

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveCell.Offset(2, 0).EntireRow.Columns("A").Select

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Workbooks.Open Filename:="P:\NoShow\tempnoshow.xls"
Sheets("Sheet1").Select

With Workbooks("TempNoShow.xls").Worksheets("Sheet1")
Columns("E:E").Select
Selection.NumberFormat = "mm/dd/yyyy"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A2:E35").Select
Selection.Copy
Windows("No_Show_2008.xls").Activate
ActiveWindow.WindowState = xlMaximized
ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select


ActiveSheet.Paste


End With

Windows("TempNoShow.xls").Close

ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Offset(1, -1).Select
ActiveWorkbook.Activate

Application.WindowState = xlMaximized

Module3.Enable_Events

End Sub




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
pastespecial Curt Excel Programming 6 July 20th 07 03:54 PM
Why need to use Selection.PasteSpecial vs myRange.PasteSpecial [email protected] Excel Programming 4 June 25th 07 05:34 PM
PasteSpecial Kevin Excel Programming 3 October 7th 04 01:07 PM
pastespecial Jeff Excel Programming 4 September 28th 04 10:30 PM
PasteSpecial KL[_3_] Excel Programming 1 July 8th 04 02:07 PM


All times are GMT +1. The time now is 09:42 AM.

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"