+ Reply to Thread
Results 1 to 2 of 2

Excel 2007 : Copy macro not working in Excel 2007

Hybrid View

  1. #1
    Registered User
    Join Date
    01-29-2010
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    1

    Copy macro not working in Excel 2007

    Hi Everyone,

    I have created a macro in excel 2003 to copy contents from another workbook. It is working well. However I am trying to run the same macro in excel 2007 , it is not working. All macros are enabled. Also other macros are running. After testing the macro, I found it the problem is in the opening files to copy. So please help in resolving the issue happening in this code.


    'Usage
    'Importing data from other workbooks
    Sub Importdata()
    Dim lCount As Long
    Dim wbResults As Workbook
    Dim wbCodeBook As Workbook
    Dim sPath As String

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.EnableEvents = False

    On Error Resume Next

    Set wbCodeBook = ThisWorkbook

    With Application.FileSearch
    .NewSearch
    'Change path to suit - here Information Input :B10 contains the path of the excel files
    .LookIn = wbCodeBook.Worksheets("Information Input").Range("B10")
    .FileType = msoFileTypeAllFiles





    If .Execute > 0 Then 'Workbooks in folder
    For lCount = 1 To .FoundFiles.Count ' Loop through all.

    'Open Workbook x and Set a Workbook variable to it
    Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)

    'Importing Data
    wbResults.Worksheets("Sheet1").Range("A2:AH10000").Copy
    wbCodeBook.Worksheets("Sheet1").Range("A" & wbCodeBook.Worksheets("Data Input").Range("A10001").End(xlUp).Row).Offset(1, 0).PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=False, Transpose:=False


    wbResults.Close SaveChanges:=False

    Next lCount


    End If
    End With


    On Error GoTo 0
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.EnableEvents = True
    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Copy macro not working in Excel 2007

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ Reply to Thread

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