+ Reply to Thread
Results 1 to 3 of 3

Run-Time Error - VBA Copy and Paste Multiple Row From One Workbook to Another

  1. #1
    Registered User
    Join Date
    02-24-2014
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    1

    Post Run-Time Error - VBA Copy and Paste Multiple Row From One Workbook to Another

    Greeting to all! I am new to VBA and also to this forum. Seeking help with vba code (see below) to copy paste data from multiple rows from one workbook to another workbook (MasterServiceHistories) located on our server on 'S' drive. I continue to get a Run-time error '1004': Method 'Open' of object 'Workbooks' failed. I am attaching a copy of my workbook (adbTESTER).

    I'm trying to use this code to copy the service history from the 'Service History' tab (activesheet) according to property address by using an ActiveX control button 'Send to File' to paste to the corresponding sheet in 'Master Service Histories' workbook that is located on our server 'S' drive.

    I would be very grateful for any help to resolve this issue.



    [Code]

    Private Sub CommandButton1_Click()
    LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row

    For i = 5 To LastRow

    If Cells(i, 1) = "100 MALLARD COVE" Then
    Range(Cells(i, 1), Cells(i, 18)).Select
    Selection.Copy


    Workbooks.Open Filename:="S:\FREDDIE MAC\Billing\MasterServiceHistories.xlsx"

    Dim p As Integer, q As Integer

    p = Worksheets.Count

    For q = 1 To p

    If ActiveWorkbook.Worksheets(q).Name = "100 MALLARD COVE" Then
    Worksheets("100 MALLARD COVE").Select
    End If

    Next q

    erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

    ActiveSheet.Cells(erow, 1).Select
    ActiveSheet.Paste
    ActiveWorkbook.Save
    ActiveWorkbook.Close
    Application.CutCopyMode = False
    End If

    Next i


    End Sub

    [Code]
    Last edited by jxc; 02-24-2014 at 04:35 PM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Run-Time Error - VBA Copy and Paste Multiple Row From One Workbook to Another

    Hi jxc,

    Try this:

    Please Login or Register  to view this content.
    BTW - Your last code tag needs a leading whack i.e. [/CODE]
    Last edited by xladept; 02-24-2014 at 08:47 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Run-Time Error - VBA Copy and Paste Multiple Row From One Workbook to Another

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks for the reps

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy ranges from multiple sheets and paste them in another workbook
    By LewisM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2014, 09:26 AM
  2. Issue with copy and paste: Run-time error 438
    By tariq2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2013, 01:01 PM
  3. Copy-Paste cells from from 1 workbook to another: Run-time error '438'
    By Mon1aa in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-05-2012, 02:47 PM
  4. copy paste from multiple workbooks to master workbook
    By ravinder_tigh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2009, 02:29 AM
  5. Replies: 1
    Last Post: 10-17-2005, 04:05 AM

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