Posts

Speeding up VBA Code that Sets Pivot Table Filters

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0; up vote 2 down vote favorite I've written out some VBA code that sets various filters onto pivottables. The problem I am experiencing is that it is extremely slow and bogs down my system heavily. I've tried implementing various things to speed up the code, but nothing really has that much of an effect. The reason I am doing it this way is the filters need to be dynamic and I am using multiple data sources, so just using a single slicer doesn't work in my case. Here is my code: Private Sub Worksheet_Calculate() Application.ScreenUpdating = False Application.EnableEvents = False Application.Calculation = xlCalculationManual Application.DisplayStatusBar = False ActiveSheet.DisplayPageBreaks = False Dim DivRef, RegRef, DistRef, ZoneRef As String DivRef = Sheet5.Range("AH6").Value RegRef = Sheet5.Range("AH7").Value ...

Cracking the coding interview 1.7 - Rotate matrix by 90 degrees

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0; up vote 4 down vote favorite The question asks to rotate an image/matrix by 90 degrees. Ideally it asks to do it in place but before that I decided to do it using extra space because this is my first time working with matrices. question: while using extra space, could this have been any better? def rotate_m1(matrix, d): """ with extra space for each row in the orginal matrix, the items position in that row will be its row in the new matrix. Its position in the new row will be determined by 'l' (matrix row length), which decrements after each loop. e.g. 1,2 3,4 the loop goes through and maps the top row to the outside of a new matrix. i.e. i = 0 # row j = 0 # col // its postion in the row l = d-1 # d = the dimensions of the matrix matrix[i][j] = 1 in the new matrix the postion of matrix[i][j] (1) will be: new_matri...