Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Error on pastespecial

Hi all,

The code below returns error at

wsPCData.UsedRange.Copy
rngData.PasteSpecial(xlPasteValuesAndNumberFormats )

Here is the error message:
Run-timed error '1004':
Unable to get the pastespecial property of the range class

I am unsure as to why I am receiving the error

Many thanks!
-goss
================
================

Option Explicit

Sub purch_GetProfitCenterData()

Dim wbBook As Workbook
Dim wbData As Workbook
Dim wsData As Worksheet
Dim wsPCData As Worksheet
Dim rngData As Range
Dim strFile As String

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

Set wbBook = ThisWorkbook
Set wsData = wbBook.Worksheets("Centers")
Set rngData = wsData.Range("A1")

'Clear current Data
wsData.UsedRange.Clear

'Open the rip file and copy all data
strFile = "C:\FoodTrak\rip-PurchRecapByPC.xls"
Set wbData = Application.Workbooks.Open(strFile)
Set wsPCData = wbData.Worksheets(1)

'Paste data and formats
wsPCData.UsedRange.Copy
rngData.PasteSpecial(xlPasteValuesAndNumberFormats )
wsPCData.UsedRange.Copy rngData.PasteSpecial(xlPasteFormats)


'Delete the rip file
Kill strFile

'Cleanup
Set wbBook = Nothing
Set wbData = Nothing
Set wsData = Nothing
Set wsPCData = Nothing
Set rngData = Nothing


With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
End With


End Sub












  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Error on pastespecial

give this a shot -- made a few minor changes.



Sub purch_GetProfitCenterData()

Dim wbBook As Workbook
Dim wbData As Workbook
Dim wsData As Worksheet
Dim wsPCData As Worksheet
Dim rngData As String
Dim strFile As String

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

Set wbBook = ThisWorkbook
Set wsData = wbBook.Worksheets("Centers")
rngData = wsData.Range("A1").Address


'Clear current Data
wsData.UsedRange.Clear

'Open the rip file and copy all data
strFile = "C:\FoodTrak\rip-PurchRecapByPC.xls"
Set wbData = Application.Workbooks.Open(strFile)
Set wsPCData = wbData.Worksheets(1)

'Paste data and formats
wsPCData.UsedRange.Copy
Range(rngData).PasteSpecial (xlPasteValuesAndNumberFormats)

'wsPCData.UsedRange.Copy rngData.PasteSpecial(xlPasteFormats)


'Delete the rip file
Kill strFile

'Cleanup
Set wbBook = Nothing
Set wbData = Nothing
Set wsData = Nothing
Set wsPCData = Nothing
'Set rngData = Nothing


With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
End With


End Sub

"-goss" wrote:

Hi all,

The code below returns error at

wsPCData.UsedRange.Copy
rngData.PasteSpecial(xlPasteValuesAndNumberFormats )

Here is the error message:
Run-timed error '1004':
Unable to get the pastespecial property of the range class

I am unsure as to why I am receiving the error

Many thanks!
-goss
================
================

Option Explicit

Sub purch_GetProfitCenterData()

Dim wbBook As Workbook
Dim wbData As Workbook
Dim wsData As Worksheet
Dim wsPCData As Worksheet
Dim rngData As Range
Dim strFile As String

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

Set wbBook = ThisWorkbook
Set wsData = wbBook.Worksheets("Centers")
Set rngData = wsData.Range("A1")

'Clear current Data
wsData.UsedRange.Clear

'Open the rip file and copy all data
strFile = "C:\FoodTrak\rip-PurchRecapByPC.xls"
Set wbData = Application.Workbooks.Open(strFile)
Set wsPCData = wbData.Worksheets(1)

'Paste data and formats
wsPCData.UsedRange.Copy
rngData.PasteSpecial(xlPasteValuesAndNumberFormats )
wsPCData.UsedRange.Copy rngData.PasteSpecial(xlPasteFormats)


'Delete the rip file
Kill strFile

'Cleanup
Set wbBook = Nothing
Set wbData = Nothing
Set wsData = Nothing
Set wsPCData = Nothing
Set rngData = Nothing


With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
End With


End Sub













  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Error on pastespecial

On Oct 2, 8:43*am, dmoney wrote:
give this a shot -- made a few minor changes.

Sub purch_GetProfitCenterData()

* * Dim wbBook As Workbook
* * Dim wbData As Workbook
* * Dim wsData As Worksheet
* * Dim wsPCData As Worksheet
* * Dim rngData As String
* * Dim strFile As String

* * Application.ScreenUpdating = False
* * Application.Calculation = xlCalculationManual
* * Application.DisplayAlerts = False

* * Set wbBook = ThisWorkbook
* * Set wsData = wbBook.Worksheets("Centers")
* * rngData = wsData.Range("A1").Address

* * 'Clear current Data
* * * * wsData.UsedRange.Clear

* * 'Open the rip file and copy all data
* * * * strFile = "C:\FoodTrak\rip-PurchRecapByPC.xls"
* * * * Set wbData = Application.Workbooks.Open(strFile)
* * * * Set wsPCData = wbData.Worksheets(1)

* * 'Paste data and formats
* * * * wsPCData.UsedRange.Copy
Range(rngData).PasteSpecial (xlPasteValuesAndNumberFormats)

* * * * 'wsPCData.UsedRange.Copy rngData.PasteSpecial(xlPasteFormats)

* * 'Delete the rip file
* * * * Kill strFile

* * 'Cleanup
* * * * Set wbBook = Nothing
* * * * Set wbData = Nothing
* * * * Set wsData = Nothing
* * * * Set wsPCData = Nothing
* * * * 'Set rngData = Nothing

* * * * With Application
* * * * * * .ScreenUpdating = True
* * * * * * .Calculation = xlCalculationAutomatic
* * * * * * .DisplayAlerts = True
* * * * End With

End Sub



"-goss" wrote:
Hi all,


The code below returns error at


wsPCData.UsedRange.Copy
rngData.PasteSpecial(xlPasteValuesAndNumberFormats )


Here is the error message:
Run-timed error '1004':
Unable to get the pastespecial property of the range class


I am unsure as to why I am receiving the error


Many thanks!
-goss
================
================


Option Explicit


Sub purch_GetProfitCenterData()


* * Dim wbBook As Workbook
* * Dim wbData As Workbook
* * Dim wsData As Worksheet
* * Dim wsPCData As Worksheet
* * Dim rngData As Range
* * Dim strFile As String


* * Application.ScreenUpdating = False
* * Application.Calculation = xlCalculationManual
* * Application.DisplayAlerts = False


* * Set wbBook = ThisWorkbook
* * Set wsData = wbBook.Worksheets("Centers")
* * Set rngData = wsData.Range("A1")


* * 'Clear current Data
* * * * wsData.UsedRange.Clear


* * 'Open the rip file and copy all data
* * * * strFile = "C:\FoodTrak\rip-PurchRecapByPC.xls"
* * * * Set wbData = Application.Workbooks.Open(strFile)
* * * * Set wsPCData = wbData.Worksheets(1)


* * 'Paste data and formats
* * * * wsPCData.UsedRange.Copy
rngData.PasteSpecial(xlPasteValuesAndNumberFormats )
* * * * wsPCData.UsedRange.Copy rngData.PasteSpecial(xlPasteFormats)


* * 'Delete the rip file
* * * * Kill strFile


* * 'Cleanup
* * * * Set wbBook = Nothing
* * * * Set wbData = Nothing
* * * * Set wsData = Nothing
* * * * Set wsPCData = Nothing
* * * * Set rngData = Nothing


* * * * With Application
* * * * * * .ScreenUpdating = True
* * * * * * .Calculation = xlCalculationAutomatic
* * * * * * .DisplayAlerts = True
* * * * End With


End Sub- Hide quoted text -


- Show quoted text -


Thanks dmoney!
The error message is gone, but nothing is pasted into the target
workbook?
Also your code removed the wb.close so the kill command error'd out
since the file was open

I need to paste the data from the rip file into the target
workbook.worksheet to include formatting
As far as I can tell I can only key on the fact that the profit center
header is Arial Bold 9 as opposed to other header lines of different
fonts and sizes

Thanks!
goss
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/pastespecial error Jon Excel Programming 5 October 29th 07 12:59 PM
PasteSpecial Method Error PW11111 Excel Discussion (Misc queries) 1 December 19th 06 01:24 PM
Error in PasteSpecial ? Corey Excel Programming 14 October 30th 06 06:10 AM
PasteSpecial error Robert Christie[_3_] Excel Programming 4 December 27th 04 10:37 PM
PasteSpecial Error sowetoddid[_14_] Excel Programming 3 April 28th 04 12:14 AM


All times are GMT +1. The time now is 12:07 AM.

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

About Us

"It's about Microsoft Excel"