title: Repeat the same calculation in multiple sheets
body: <p>Task: Repeat an identical calculation in multiple sheets.</p>
  
  <p>Background:</p>
  
  <ol>
  <li><p>multiple sheets labelled by calendar date i.e. 01 04, 02 04, 03 04. These are three discrete sheet names meaning 1st April, 2nd April and 3 April. (actual workbook has all the days in the month).</p></li>
  <li><p>Data has identical column headings, but the number of rows vary. In brief the data is a list of mastercard and visa transactions.</p></li>
  <li><p>I want to get the total of column G (happens to contain the monetary transaction value) and only take the Visa transactions.</p></li>
  </ol>
  
  <p>Result:</p>
  
  <p>the code below does this fine and places the results on the same sheet merely offset by a few columns to the right hand side and highlights the value I need in red. (this is a recorded macro I completed)</p>
  
  <p>Limitation and seeking advise:</p>
  
  <p>1) improve code to repeat this for all sheets by a single click of a mouse button.
  (as you will note, its about how to cycle through all the sheets within the same workbook rather than (at present) having to manually go into each sheet and run the macro.</p>
  
  <p>thank you in advance</p>
  
  <p>code is:</p>
  
  <pre><code>Sub sum_visa_trans_together()
  '
  ' sum_visa_trans_together Macro
  '
  ' Keyboard Shortcut: Ctrl+r
  '
  ActiveCell.Rows("1:1").EntireRow.Select
  Selection.AutoFilter
  ActiveSheet.Range("$A$1:$M$14").AutoFilter Field:=2, Criteria1:="V"
  ActiveCell.Offset(0, 6).Columns("A:A").EntireColumn.Select
  Selection.Copy
  ActiveCell.Offset(0, 4).Range("A1").Select
  ActiveSheet.Paste
  ActiveCell.Rows("1:1").EntireRow.Select
  Application.CutCopyMode = False
  Selection.AutoFilter
  ActiveCell.Offset(0, 11).Range("A1").Select
  ActiveCell.FormulaR1C1 = "max"
  ActiveCell.Offset(1, 0).Range("A1").Select
  ActiveCell.FormulaR1C1 = "=MAX(C[-1])"
  ActiveCell.Offset(1, 0).Range("A1").Select
  ActiveCell.FormulaR1C1 = "=SUM(C[-1])"
  ActiveCell.Offset(1, 0).Range("A1").Select
  ActiveCell.FormulaR1C1 = "visa trans"
  ActiveCell.Offset(1, 0).Range("A1").Select
  ActiveCell.FormulaR1C1 = "=R[-2]C-R[-3]C"
  ActiveCell.Select
  With Selection.Font
      .Color = -16776961
      .TintAndShade = 0
  End With
  Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  With Selection.Borders(xlEdgeLeft)
      .LineStyle = xlContinuous
      .ColorIndex = 0
      .TintAndShade = 0
      .Weight = xlMedium
  End With
  With Selection.Borders(xlEdgeTop)
      .LineStyle = xlContinuous
      .ColorIndex = 0
      .TintAndShade = 0
      .Weight = xlMedium
  End With
  With Selection.Borders(xlEdgeBottom)
      .LineStyle = xlContinuous
      .ColorIndex = 0
      .TintAndShade = 0
      .Weight = xlMedium
  End With
  With Selection.Borders(xlEdgeRight)
      .LineStyle = xlContinuous
      .ColorIndex = 0
      .TintAndShade = 0
      .Weight = xlMedium
  End With
  Selection.Borders(xlInsideVertical).LineStyle = xlNone
  Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  End Sub
  </code></pre>