+ Reply to Thread
Results 1 to 5 of 5

Making the run of Macro not visible

Hybrid View

  1. #1
    Registered User
    Join Date
    12-17-2008
    Location
    Singapore
    MS-Off Ver
    2002
    Posts
    71

    Making the run of Macro not visible

    Hi all, I have a macro that will locate files in a folder, then it will copy the worksheets and paste into the current workbook.

    However It need to open up to 100 workbooks and copy and paste into the new workbook. During the run of the macro, I can see files opening and closing on the toolbar. is that possible to make those opening and closing of files not seen by the user?

    Pls Advise.

    Sub RunCodeOnAllXLSFiles()
       Application.ScreenUpdating = False
       Application.DisplayAlerts = False
       Application.EnableEvents = False
    
    
        'Macro code to copy from multiple workbooks to current workbook
    
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
        Application.EnableEvents = True
    
    End Sub

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Making the run of Macro not visible

    Does the rest of your code activate or select the workbooks?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-17-2008
    Location
    Singapore
    MS-Off Ver
    2002
    Posts
    71

    Re: Making the run of Macro not visible

    yes, the macro works like this. It will search through the folder for file name containing a cell value. Once Found, it will open the workbook and copy the entire sheet and paste to the new workbook. Once copied, it will close the workbook and continue to search for files in the directory till all are compared.

    If the filename does not contain what the cell value specify, it will not open the files.

    If we can see the opening and closing of the workbooks during the macro run, is that normal ? or is that a way to hide those ?
    Last edited by kaffal; 03-08-2009 at 10:17 AM.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Making the run of Macro not visible

    You don't need to activate or select these workbooks and/or sheets - this will result in faster, more efficient ode & remove theflashing effect.

  5. #5
    Registered User
    Join Date
    12-17-2008
    Location
    Singapore
    MS-Off Ver
    2002
    Posts
    71

    Re: Making the run of Macro not visible

    Hi royUK,
    sorry I new to VB, I dun get what you mean
    Maybe you could take a look at my code and comment

    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)
    
    
                     'DO YOUR CODE HERE
                      TabName = TabNam & Range("A1").Value
                      EmptyCell = Range("B3").Value
                      If EmptyCell <> "" Then
                         ActiveSheet.Name = TabName
                                      
                         Sheets(TabName).Copy After:=wbCodeBook.Sheets(1)
                         i = i + 1
                                                            
                         wbCodeBook.Sheets("Menu").Cells(i, 2).Value = "Completed"
                         wbCodeBook.Sheets("Menu").Cells(i + 10, 3).Value = TabName
                      
                      
                      End If
                      wbResults.Close SaveChanges:=False
                     Next lCount
                     
                End If

+ 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