View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GJones GJones is offline
external usenet poster
 
Posts: 132
Default PasteSpecial Error

Maybe the xlPasteValuesAndNumberFormats call is generating
an error because some of the values are not numbers
-----Original Message-----
I have been trying to run this macro but continue to get

a "PasteSpecial
Method of Range Class Failed" error. Any ideas?


Sub testIt()
Dim ThisWB As Workbook, OpenedWB As Workbook, _
OpenFileName As Variant
Set ThisWB = ThisWorkbook
OpenFileName = Application.GetOpenFilename()
If LCase(TypeName(OpenFileName)) = "boolean" Then
Else
Set OpenedWB = Workbooks.Open(OpenFileName)
OpenedWB.Sheets(1).Range("A1:Z100").Copy
ThisWB.Worksheets("sheet1").Range("b1").PasteSpec ial _
xlPasteValuesAndNumberFormats
OpenedWB.Close False
End If
End Sub


---
Message posted from http://www.ExcelForum.com/

.