Results 1 to 6 of 6

VBA Lookup errors

Threaded View

  1. #1
    Registered User
    Join Date
    06-18-2012
    Location
    Batlimore, MD
    MS-Off Ver
    Excel 2007
    Posts
    8

    Angry VBA Lookup errors

    I am writing a macro that needs to look up data in a different workbook in the first sheet with a particular name. I need to copy all the data from the sheet into a select worksheet in a select workbook.

    I have the following code so far.

    Sub CopyCells(smallname As String, sheetname As String, LocoName As String, cells As Range, Bookinto As String, Sheetinto As String)
        Workbooks.Open Filename:=LocoName
        Workbooks(smallname).Activate
        Worksheets(sheetname).Activate
        Range("A1:Z1000").Select
        ActiveSheet.Copy
    
        Workbooks(Bookinto).Activate 'activate book
        Worksheets(Sheetinto).Activate
        Range("A1").Select
        ActiveSheet.Paste
        Workbooks(smallname).Close
    End Sub
    It works fine with debugging however when I try to copy the information from the files it does not copy but makes a new version of it called Book3. then it closes the original. this is fine but not really useful...
    I am sure i am making a silly mistake can anyone find it?
    Last edited by Leith Ross; 06-18-2012 at 11:05 AM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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