Vous êtes sur la page 1sur 3

Sub Formatting()

Dim i As Integer

Application.ScreenUpdating = False

Set FirstRowLastColumn = Cells(ActiveSheet.UsedRange.Row, 200).End(xlToLeft)

Set FirstRowFirstColumn = Cells(ActiveSheet.UsedRange.Row,


ActiveSheet.UsedRange.Column)

Set HeaderRange = Range(FirstRowLastColumn, FirstRowFirstColumn)

HeaderRange.Select

With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark2
.TintAndShade = -9.99786370433668E-02
.PatternTintAndShade = 0
End With
Selection.Borders.LineStyle = xlContinuous
Selection.Font.Bold = True
Cells.Select
Cells.EntireColumn.AutoFit

ActiveSheet.UsedRange.Font.Size = 10

ActiveSheet.UsedRange.NumberFormat = "0"

FirstRowFirstColumn.Select

Application.ScreenUpdating = True

'StartCounter = FirstRowFirstColumn.Column

'EndCounter = FirstRowLastColumn.Column

'Counter = EndCounter - StartCounter + 1

'For i = StartCounter To EndCounter

'ISInteger (Cells(ActiveSheet.UsedRange.Row + 1, StartCounter).Value)

End Sub
Sub CreateDynamicPivot()

'PURPOSE: Creates a brand new Pivot table on a new worksheet from data in the
ActiveSheet
'Source: www.TheSpreadsheetGuru.com

Dim sht As Worksheet


Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
Dim PivotDataSourceRange As Range
Dim pvtFld As PivotField

Application.ScreenUpdating = False

Set PivotDataSourceRange = ActiveSheet.UsedRange

'Determine the data range you want to pivot


SrcData = ActiveSheet.Name & "!" &
ActiveSheet.UsedRange.Address(ReferenceStyle:=xlR1C1)

'Create a new worksheet


Set sht = Sheets.Add

'Where do you want Pivot Table to start?


StartPvt = sht.Name & "!" & sht.Range("A3").Address(ReferenceStyle:=xlR1C1)

'Create Pivot Cache from Source Data


Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=SrcData)

CurrentPivotTableName = "PivotTable" & Now

'Create Pivot table from Pivot Cache


Set pvt = pvtCache.CreatePivotTable( _
TableDestination:=StartPvt, _
TableName:=CurrentPivotTableName)
Range("C3").Select
ActiveSheet.PivotTables(CurrentPivotTableName).TableStyle2 = ""

For Each pvtFld In pvt.ColumnFields

ActiveSheet.PivotTables(CurrentPivotTableName).PivotFields( _
pvtFld.Name).Subtotals = Array(False, False, False, False, False, False,
False, _
False, False, False, False, False)

Next

With ActiveSheet.PivotTables(CurrentPivotTableName)
.ColumnGrand = False
.RowGrand = False
End With
ActiveSheet.PivotTables(CurrentPivotTableName).RepeatAllLabels _
xlRepeatLabels
Range("C4").Select
With ActiveSheet.PivotTables(CurrentPivotTableName)
.HasAutoFormat = False
.InGridDropZones = True
.RowAxisLayout xlTabularRow
End With

Formatting

End Sub

Sub Sum_Visible_Cells()

'Application.Volatile

Set Cells_To_Sum = Selection


For Each Cell In Cells_To_Sum
If Cell.Rows.Hidden = False Then
If Cell.Columns.Hidden = False Then
Total = Total + Cell.Value
End If
End If
Next

MsgBox "Total Sum is --> " & Total

End Sub

Sub Copy_Paste_VisibleCells()

ColumnNum = ActiveCell.Column

'Set Visible_Range = Range(Cells(2, ColumnNum), Cells(99999,


ColumnNum).End(xlUp)).SpecialCells(xlCellTypeVisible)

Set Visible_Range = Selection.SpecialCells(xlCellTypeVisible)

For Each Cell In Visible_Range


If Cell.Rows.Hidden = False Then
If Cell.Columns.Hidden = False Then
Cell.Value = Cell.Value
End If
End If
Next

End Sub

Vous aimerez peut-être aussi