Thursday 26 September 2013

Excel Macros - add totals to every sheet

Watch on YouTube


This macro will add totals after last record in every sheet 

Sub Test()
Dim ws As Worksheet
    For Each ws In Sheets

        ws.Activate
        Dim lastRowWithData As Long
        lastRowWithData = Range("A" & Rows.Count).End(xlUp).Row + 1
        Range("F" & lastRowWithData).FormulaR1C1 = "=Sum(R2C:R[-1]C)"
        Range("G" & lastRowWithData).FormulaR1C1 = "=Sum(R2C:R[-1]C)"
        Range("H" & lastRowWithData).FormulaR1C1 = "=Sum(R2C:R[-1]C)"
        Range("I" & lastRowWithData).FormulaR1C1 = "=Sum(R2C:R[-1]C)"
    Next ws
End Sub

Wednesday 25 September 2013

Excel - How to fix error - Cannot edit a macro on a hidden workbook. Unhide the workbook using the Unhide command

Wanch this example on YouTUbe

If you are getting the following error

 Cannot edit a macro on a hidden workbook.  Unhide the workbook using the Unhide command


simply click view tab





and select unhide

Excel - Apply macro to all worksheets


Watch step by step example on YouTube

Replace

Sub Test()
'
' Test Macro
'
'
        Cells.Select
        Cells.EntireColumn.AutoFit
        Rows("1:1").Select
        Selection.Font.Bold = True
        With ActiveWindow
            .SplitColumn = 0
            .SplitRow = 1
        End With
        ActiveWindow.FreezePanes = True
        Sheets("Sheet1").Select

End Sub

With

Sub Test()
'
' Test Macro
'

'

Dim ws As Worksheet

    For Each ws In Sheets
        ws.Activate

   
        Cells.Select
        Cells.EntireColumn.AutoFit
        Rows("1:1").Select
        Selection.Font.Bold = True
        With ActiveWindow
            .SplitColumn = 0
            .SplitRow = 1
        End With
        ActiveWindow.FreezePanes = True
        Sheets("Sheet1").Select
    Next ws
End Sub

Tuesday 3 September 2013

WCF - How to fix error System.InvalidOperationException: The contract name 'GettingStartedLib.IService1' could not be found in the list of contracts implemented by the service 'CalculatorService'.

Error Message:

System.InvalidOperationException: The contract name 'GettingStartedLib.IService1' could not be found in the list of contracts implemented by the service 'CalculatorService'.

In order to fix it in App.Config replace

      <service name="GettingStartedLib.CalculatorService">
        <endpoint address="" binding="wsHttpBinding" contract="GettingStartedLib.IService1">
          <identity>

with      
<service name="GettingStartedLib.CalculatorService">
        <endpoint address="" binding="wsHttpBinding" contract="GettingStartedLib.ICalculator">
          <identity>