Friday, June 3, 2016

Excel Tutorial Part2

Continuing with the tutorial, below more videos.

Fourth TIP

How to run Macros when the excel file opens 


Code:

Private Sub Workbook_Open()
Application.DisplayAlerts = True
ActiveWorkbook.RefreshAll

MsgBox ("Before start, please check that the sheet Names is update with all the eNBs.")
End Sub


Fifth TIP

How to manage or control a PivoTable using VB

Code:

Sub Loop_PivotItems()

Application.DisplayAlerts = False

Sheets("Final Table").Select
'Store the sheet with the Pivot Table
Piv_Sht = ActiveSheet.Name
'Loop through every PivotItem in the PageField (Filter) of the Pivot Table
For Each PivotItem In ActiveSheet.PivotTables(1).PageFields(1).PivotItems
'Select the PivotItem
    ActiveSheet.PivotTables(1).PageFields(1).CurrentPage = PivotItem.Value
'Do whatever you need here....
  'MsgBox (PivotItem.Value)
 photo
'Return to sheet with the Pivot Table
Sheets(Piv_Sht).Select

Next
MsgBox ("All picture update")

Application.DisplayAlerts = True

End Sub

Sixth TIP

Run a Macro when something changes in the sheet Excel.


Code:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    ' The variable KeyCells contains the cells that will
    ' cause an alert when they are changed.
    Set KeyCells = Range("C1")
   
    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
           Is Nothing Then

        ' Display a message when one of the designated cells has been
        ' changed.
        ' Place your code here.
        'MsgBox "Cell " & Target.Address & " has changed."
       agregar_fecha1
       Sheets("Graph").Select
     
    End If
End Sub

No comments:

Post a Comment