title: VBA code to run on all workbooks with conditions
body: <p>Apart from manual book keeping I keep all of my data related to installment sales saved in Excel files. I use a template which is like an invoice but also shows due dates, payment dates, amount of installment paid &amp; remaining balance of the customer. </p>
  
  <p>I am currently managing sales data of 4 of our branches. The folders I have are <em>Branch-1, Branch-2, Branch-3 &amp; Branch-4</em>. </p>
  
  <p>Each of these folders contains subfolders named according to year of sales like from year 2006 to 2015 &amp; has 12 workbooks each (Jan 2006.xls, Feb 2006.xls &amp; so on till March 2015.xls in folder named 2015). Each of these workbooks has different numbers of worksheets named according to the account number assigned to the customer.</p>
  
  <p>I am searching for a solution to run the code with certain conditions in all of my workbooks in a folder. I use simple code which goes through all worksheets in a workbook, extracts data from certain cells in all worksheets &amp; creates a summary in a worksheet named ‘Summary’ by pasting the data row wise.</p>
  
  <pre><code>Sub Create_Summary()
  
  Dim wksht As Worksheet: Set wksht = Sheets("Summary")
  Dim ws As Worksheet
  Dim LR As Long
  
  Application.ScreenUpdating = False
  
  For Each ws In Worksheets
  
      If ws.Name &lt;&gt; wksht.Name Then
  
          LR = wksht.Range("A" &amp; Rows.Count).End(xlUp).Row + 1
  
          wksht.Range("A" &amp; LR) = ws.Range("H2")
          wksht.Range("B" &amp; LR) = ws.Range("B2")
          wksht.Range("C" &amp; LR) = ws.Range("B4")
          wksht.Range("D" &amp; LR) = ws.Range("C2")
          wksht.Range("E" &amp; LR) = ws.Range("B3")
          wksht.Range("F" &amp; LR) = ws.Range("E3")
          wksht.Range("G" &amp; LR) = ws.Range("H3")
          wksht.Range("H" &amp; LR) = ws.Range("H1")
          wksht.Range("I" &amp; LR) = ws.Range("F48")
          wksht.Range("J" &amp; LR) = ws.Range("H13")
          wksht.Range("K" &amp; LR) = ws.Range("H12")
          wksht.Range("L" &amp; LR) = ws.Range("H14")
          wksht.Range("M" &amp; LR) = ws.Range("H15")
  
      End If
  
  Next ws
  
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>I run this code in all of my workbooks, which is time consuming. I have to custom format the summary sheet by adding header, headings in column, set the desired column width etc. Then I have to copy all sheet &amp; paste in a another workbook to complete the master summary for any branch so that I have complete customer info from year 2006 to 2015 in either branches. Apart from the master summary sheet, I have to prepare two more sheets, one which shows customers with remaining balance &amp; the other which shows remaining balance with a condition i.e. H13 has data more than 0 (H13>0) in omitting any account with H13=0.</p>
  
  <p>I am looking for a macro or maybe 3 macros (considering 2 conditions I mentioned above) that runs through all of my workbooks (excluding a sheet named Summary which is in every workbook) branch wise, collect data from cells, paste into one master sheet row wise with column headings, sets column width according to space occupied by text in a cell, with the main header as Branch folder name &amp; shows date - time when summary is created. I possess a very limited expertise on Excel &amp; a will to learn more therefore any kind of assistance will be highly appreciated.</p>
  
  <p>I am attaching files for better understanding of my requirement.</p>
  
  <p>File: February 2014.xls
  HTML Code:
  <a href="https://drive.google.com/file/d/0B0L43wu5SnIoWklmNTVNSnNHbWM/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B0L43wu5SnIoWklmNTVNSnNHbWM/view?usp=sharing</a></p>
  
  <p>File: March 2014.xls
  HTML Code:
  <a href="https://drive.google.com/file/d/0B0L43wu5SnIoQjRTdnRCRGxLRWM/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B0L43wu5SnIoQjRTdnRCRGxLRWM/view?usp=sharing</a></p>
  
  <p>These 2 files are example files from Branch 1 folder named 2014.</p>