+ Reply to Thread
Results 1 to 3 of 3

Issue faced when macro pastes into file

Hybrid View

  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    3

    Post Issue faced when macro pastes into file

    I am gettig an error while my macro paste's something in the mentioned file.
    please can some one help me solve the error.

    macro pasted below.

    
    Sub tg()
    
        
        Set xlApp = New Excel.Application
        Set xlApp1 = New Excel.Application
        Set xlApp2 = New Excel.Application
        Set xlApp3 = New Excel.Application
        
        xlApp.Visible = True
        xlApp1.Visible = True
        xlApp2.Visible = True
        xlApp3.Visible = True
        
        Set xlBook = xlApp.Workbooks.Open("I:\GoPricing\Tofiq\global_imagine.csv")
        
        If ActiveSheet.UsedRange.Rows.Count > 150000 Then
        
        Application.CutCopyMode = False
        'xlApp.Range("A2").Select
        xlApp.Rows("2:75000").Select
        xlApp.Selection.Copy
        Set xlbook1 = xlApp1.Workbooks.Open("I:\GoPricing\Tofiq\Milenium-Cleanup1.xlsm")
        xlApp1.Range("A2").Select
        xlApp1.ActiveSheet.Paste
        xlbook1.Save
    '    xlbook1.Close
            
        
        xlApp.Workbooks(1).Activate
        
        
        Application.CutCopyMode = False
        xlApp.Rows("75001:150000").Select
        xlApp.Selection.Copy
        Set xlbook2 = xlApp2.Workbooks.Open("I:\GoPricing\Tofiq\Milenium-Cleanup2.xlsm")
        xlApp2.Range("A2").Select
        xlApp2.ActiveSheet.Paste
        xlbook2.Save
    '    xlbook2.Close
        
        
        xlApp.Workbooks(1).Activate
        
        Application.CutCopyMode = False
        xlApp.Rows("150001:250000").Select
        xlApp.Selection.Copy
        Set xlbook3 = xlApp3.Workbooks.Open("I:\GoPricing\Tofiq\Milenium-Cleanup3.xlsm")
        xlApp3.Range("A2").Select
        xlApp3.ActiveSheet.Paste
        Application.CutCopyMode = False
        xlbook3.Save
    '    xlbook3.Close
        xlBook.Close
        
        Else
        
        
        Application.CutCopyMode = False
        'xlApp.Range("A2").Select
        xlApp.Rows("2:75000").Select
        xlApp.Selection.Copy
        Set xlbook1 = xlApp1.Workbooks.Open("I:\GoPricing\Tofiq\Milenium-Cleanup1.xlsm")
        xlApp1.Range("A2").Select
        xlApp1.ActiveSheet.Paste
        xlbook1.Save
    '    xlbook1.Close
            
        
        xlApp.Workbooks(1).Activate
        
        
        Application.CutCopyMode = False
        xlApp.Rows("75001:150000").Select
        xlApp.Selection.Copy
        Set xlbook2 = xlApp2.Workbooks.Open("I:\GoPricing\Tofiq\Milenium-Cleanup2.xlsm")
        xlApp2.Range("A2").Select
        xlApp2.ActiveSheet.Paste
        xlbook2.Save
    '    xlbook2.Close
    
        End If
        
        
    
    
    End Sub
    Last edited by tofiq_golkhaw; 03-29-2012 at 10:02 AM. Reason: wrong title.

  2. #2
    Registered User
    Join Date
    01-09-2012
    Location
    mumbai
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Issue faced when macro pastes into file

    pls can someone assist me in this....

  3. #3
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Issue faced when macro pastes into file

    What is the error? On which line? Why are you using 4 Excel.Application statements?

+ Reply to Thread

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