Skip to content

Instantly share code, notes, and snippets.

@harsha547
harsha547 / Pivot Table Clear
Created June 7, 2017 18:04
Clear Existing Pivot Table
Public Sub ClearExistingTable()
Dim Piv As PivotTable
For Each Piv In cnPivot.PivotTables
Piv.TableRange2.Clear
Next Piv
End Sub
@harsha547
harsha547 / Create Pivot_Table
Last active June 7, 2017 17:56
Pivot Table VBA
private sub createpivot()
On Error Goto EH:
Dim ptCache As PivotCache
Set ptCache = ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase _
, SourceData:= chRoyaltyReport.ListObjects("tabRoyalty) _
, Version:=xlPivotTableVersion15)
' ChRoyaltyReport Worksheet name
Sub First_Method()
For i = 1 To 7
On Error GoTo Tab1:
Range("B" & i).Value = Range("A" & i).Value + i
NextCol:
Next i
@harsha547
harsha547 / post-save-hook.py
Created May 30, 2017 08:24 — forked from jbwhit/post-save-hook.py
Saves Jupyter Notebooks as .py and .html files automatically. Add to the ipython_notebook_config.py file of your associated profile.
import os
from subprocess import check_call
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py and .html files."""
if model['type'] != 'notebook':
return # only do this for notebooks
d, fname = os.path.split(os_path)
check_call(['ipython', 'nbconvert', '--to', 'script', fname], cwd=d)
check_call(['ipython', 'nbconvert', '--to', 'html', fname], cwd=d)
@harsha547
harsha547 / Books
Last active May 29, 2017 17:03
Python Books
Books
--- Programming Collective Intelligence Paperback Tony Segaran
-- Text Processing in Python Paperback – David Mertz
Libraries
@harsha547
harsha547 / DAX Reference Guide
Last active May 26, 2017 13:49
DAX Reference Guide
https://stackoverflow.com/questions/44187150/power-bi-dax-how-do-i-count-rows-in-one-table-based-on-values-in-another-table
https://stackoverflow.com/questions/44108244/dax-min-value-from-family
@harsha547
harsha547 / SSIS Design Patterns
Last active May 25, 2017 18:56
SSIS Design Patterns
https://stackoverflow.com/questions/23059397/handling-files-with-different-structure-for-each-loop-ssis?rq=1
https://stackoverflow.com/questions/2830711/create-a-new-table-and-import-data-from-csv-file-into-sql-server-2005
https://stackoverflow.com/questions/6735733/what-are-the-differences-between-merge-join-and-lookup-transformations-in-ssis
@harsha547
harsha547 / VBA Best Practices
Last active May 25, 2017 15:52
VBA Best Practices
https://stackoverflow.com/documentation/excel-vba/1107/vba-best-practices/9292/avoid-using-select-or-activate#t=201705241336442838007
https://blogs.office.com/2009/03/12/excel-vba-performance-coding-best-practices/
https://fastexcel.wordpress.com/2011/05/25/writing-efficient-vba-udfs-part-1/
https://fastexcel.wordpress.com/page/2/?s=writing+efficient
http://use-the-index-luke.com/anatomy
@harsha547
harsha547 / IPL_24.SQL
Created April 16, 2017 15:32
Top Ten Highest Scores in IPL ( 2008 - 2016 )
-- Top Ten Highest Scores in IPL ( 2008 - 2016 )
SELECT Top 10 A.Match_Id , C.Player_Name , SUM(B.Runs_Scored) As 'Runs'
FROM Ball_by_Ball A
INNER JOIN Batsman_Scored B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id ,B.Ball_Id ,B.Innings_No)
INNER JOIN Player C
ON A.Striker = C.Player_Id
@harsha547
harsha547 / IPL_23.SQL
Created April 16, 2017 15:18
Players with most Centuries in IPL ( 2008 - 2016 )
-- Players with most Centuries in IPL ( 2008 - 2016 )
WITH CTE ( Match_Id , Player_Name , Runs )
As
(
SELECT A.Match_Id , C.Player_Name , SUM(B.Runs_Scored) As 'Runs'
FROM Ball_by_Ball A
INNER JOIN Batsman_Scored B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id ,B.Ball_Id ,B.Innings_No)