Results 1 to 6 of 6

solve on runtime error

Threaded View

  1. #1
    Registered User
    Join Date
    07-13-2010
    Location
    Hong Kong
    MS-Off Ver
    Excel 2003
    Posts
    3

    Unhappy solve on runtime error

    Hi really need your help
    I am very new in vba
    please see below my vba.(excel2003)
    I create a vba want to copy a range of data and paste value to other workbook.
    it is work fine is file "D:\import.csv" isn't open
    but when D:\import.csv is open it get runtime error 1004 PasteSpecial method of Range Class failed. get any clue??

    Sub import_SGG()
    '
    ' import_SG Macro
    ' Macro recorded 7/12/2010 by Fonz Tsui
    'Application.CutCopyMode = False
        Range("A2:L50").Select
        Selection.Copy
    'Check if import_HSSSG is open
        Dim wb As Workbook
        On Error Resume Next
        Set wb = Workbooks("D:\import.csv")
        On Error GoTo 0
        If wb Is Nothing Then
        Workbooks.Open Filename:="D:\import.csv"
        Else
        Workbooks("import.csv").Activate
    
        End If
    
     ActiveSheet.Range("A2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    End Sub
    Last edited by fonzt; 07-15-2010 at 10:02 AM. Reason: to comply rule 3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1