+ Reply to Thread
Results 1 to 4 of 4

vba to open closed files remove filter and unhide all hiden colum of opencallsht in folder

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    vba to open closed files remove filter and unhide all hiden colum of opencallsht in folder

    Dear Experts

    I have more than 300 xlsb files in target folder all 300 xl files contains sheet Name "Opencall" In data range met filter and unhide some columns

    i want remove filter and unhide all hidden columns in OPencall sheet in every workbooks through run the vba...

    this is target path "C:\Users\mani\Desktop\OPENCALLS_PERF\Consolidattion"

    find the attachment...
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: vba to open closed files remove filter and unhide all hiden colum of opencallsht in fo

    Hi breadwinner,

    Try the attached file.

    Lewis

    Code follows:
    Option Explicit
    
    Sub ProcessXlsbFiles()
    
      Dim sPath As String
      Dim sPathAndFileName As String
      Dim sFileName As String
      Dim iCount As Long
      Dim iRow As Long
      
      'Clear the output range
      ThisWorkbook.Sheets("Sheet1").Rows("21:65000").Clear
    
      'Get the folder name
      sPath = Trim(ThisWorkbook.Sheets("Sheet1").Range("D3").Text)
      If Len(sPath) = 0 Then
        Debug.Print "There is no Folder Name specified in 'Sheet1' Cell 'D3'."
      End If
      
      'Make sure the path has a trailing backslash
      If Right(sPath, 1) <> "\" Then
        sPath = sPath & "\"
      End If
      
      'Define the row before the first output row number
      iRow = 20
    
      'Create the path and file name for the first file find
      sPathAndFileName = sPath & "*.xlsb"
    
      'Find the first file
      sFileName = Dir(sPathAndFileName)
      
      'Loop until all matching files have been found
      While Len(sFileName) > 0
        'Debug.Print sPath & sFileName
        
        'Increment the found file count
        iCount = iCount + 1
        
        'Output a message
        iRow = iRow + 1
        ThisWorkbook.Sheets("Sheet1").Cells(iRow, 1) = _
          iCount & " Processing file - " & sFileName
          
        'Scroll down so the user can follow progress
        ActiveWindow.SmallScroll Down:=1
        
        'Process the next file
        Call ProcessOneFile(sPath & sFileName)
        
        'Search for the next matching file
        sFileName = Dir()
      Wend
      
      If iCount = 0 Then
        iRow = iRow + 1
        ThisWorkbook.Sheets("Sheet1").Cells(iRow, 1) = "There were NO .xlsb files to process."
      End If
    
    End Sub
    
    Function ProcessOneFile(sPathAndFileName As String) As Long
    
      Dim ws As Worksheet
      
      On Error GoTo ERROR_EXIT:
    
      'Open the file
      Workbooks.Open FileName:=sPathAndFileName
      
      'Set the worksheet object
      Set ws = ActiveWorkbook.Sheets("OPencall")
      
      'Turn AutoFilter Off on the specified sheet
      ws.Cells.AutoFilter
      
      'Unhide all columns in the specified sheet
      ws.Cells.EntireColumn.Hidden = False
      
      'Save the file and inhibit 'Do you really want to messages'
      Application.DisplayAlerts = False
      ActiveWorkbook.Close SaveChanges:=True
      Application.DisplayAlerts = True
    
      Exit Function
      
    ERROR_EXIT:
    
      'Set failure error return
      ProcessOneFile = 1
      ActiveWorkbook.Close SaveChanges:=False
    
    End Function

  3. #3
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: vba to open closed files remove filter and unhide all hiden colum of opencallsht in fo

    Perfect Sir, Brilliant Code...Thanks alot. Solved

  4. #4
    Registered User
    Join Date
    05-25-2016
    Location
    Mumbai
    MS-Off Ver
    7
    Posts
    1

    Re: vba to open closed files remove filter and unhide all hiden colum of opencallsht in fo

    Sir I am new to the VBA programming.

    I want to use same code but some customization required. If You can help me I will be very thank full to you.

    In the above macro.
    1. Go to specific folder
    2. open all the Xl files
    3. Unhide & remove filter of all the sheet in the workbook.
    4. Save & Close the file.

+ 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] Save/Closed only macro related files and leave unrelated files open in excel?
    By rdowney79 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-12-2013, 04:17 PM
  2. Combine Data from Closed Files within the same folder
    By lasjbp9 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2013, 10:07 AM
  3. Open every file in the folder, remove merge and wrap, save and close files
    By abdesai in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2013, 04:58 PM
  4. [SOLVED] Open all files in a SharePoint folder (Problem: Files open out of order)
    By holmstarrunner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2012, 10:13 AM
  5. [SOLVED] Why can't I unhide a hiden row
    By JBurke in forum Excel General
    Replies: 7
    Last Post: 01-08-2005, 12:06 PM

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