Showing posts with label excel. Show all posts
Showing posts with label excel. Show all posts

Sunday, 12 March 2017

MS Excel - Copy Sum of Selected Cells

Problem:


Mirosoft Excel is a wonderful office product and is an essential tool in our work life for most of us. But still many would have not discovered its capabilities to the fullest. Here is a problem that I wanted to solve. Typically, techies don't like to do same thing repeatedly and would look for a possible shortcut for that. I have been working through multiple excel sheets, where in have to find totals for a group of cells, without any specific parameters to determine the qualifying cells. If there is a shortcut to accomplish this it would be of help to many.


Solution:


Given that there are no parameters that determine the qualifying cells, it is difficult to come up with a an algorithm to automate the selection and totalling. But it would be possible to leave the selection to the users and then facilitate the summing part. We can leverage the clipboard to achieve this. Let the users select the desired cells and then invoke the macro using the assigned short cut key combination and the total is copied into the clipboard and available for pasting any where.

Here is the macro that does the work:

Sub mySum()   
 Dim MyDataObj As New DataObject   MyDataObj.SetText Application.Sum(Selection)   MyDataObj.PutInClipboard 
End Sub

I am sure every one knows how to create a macro and assign a short cut key for it. You may find a lot of resources on creating a macro in excel.

Saturday, 11 February 2017

MS Excel - How to get rid of the GetPivotData function in formulas?

Problem:

Have you tried copying a formula involving cells within a pivot table? You may find that the the value in the target cells don't change. You may also notice that the formula doesn't refrerence the cells in the usual way like A1, C2, etc. Instead, it uses the GetPivotData function. for example when I tried creating a formula adding J4 and I4 and that both J4 and I4 within a Pivot Table. But the formula you see in the target cell is something like the one below:

=GETPIVOTDATA("Sum of Dec'16"|$A$3|"Group"|"Administrative Expenses")+GETPIVOTDATA("Sum of Nov'16"|$A$3|"Group"|"Administrative Expenses")

As copying this formula to the adjoining cell does not change the cell reference and as such the value doesn't change. How do we workaround this issue?

Solution:

I am sure while creating the formula, you would have used the mouse to select the cells referenced in the formula. Try just typing the cell references in the formula without using the mouse. For instance, just type '=J4+I4' and there you go, the formula remains as it is and at this instance you don't see the reference to the GetPivotData function. Now you copy this formula to the adjoining cells and it works as usual and no issues. So the issue is when you select the cells referenced in the formula using the mouse / touch pad.

Now why Excel behaves like this, we don't know. However, if you don't like this behavior and permanently disable this you need to do this. It's simple.

Bring up the Excel Options by clicking on File --> Options menu. May be, there are different ways of reaching out to the Excel Options in different versions of Excel. Under the Formulas Tab, you will find a check box 'Use GetPivotData functions for Pivot Table References' under Working with formulas section. Given below is a screen shot of Excel 2016.



There you go, just uncheck this checkbox and Excel won't use the GetPivotData function any more.



Sunday, 2 November 2014

Excel Pivot & Shortcut Keys

Question:

I understand Microsoft Excel is a good start for analytics on data. Please direct me as to how to create a basic Pivot Table. You may also share me any tutorial references to learn more on Pivot feature in Excel. Also share Short Cut keys in Excel

By: Vinay Kumar

Response:

Learning to create a Pivot is fairly easy but the tough part is to know how you want the data to be presented in the Pivot. For this you need to know a good understanding of the data on hand and what you want out of the data. For this question, I assume that you are already clear about your needs.

Here is how you can quickly get a Pivot of your Excel Data:

  • Select the data range that you want to apply Pivot on and then click on the Pivot button, which is in the Toll bar ribbon under the Insert Menu. You may also use the short cut key Alt + NV
  • This will open up the Pivot dialog window where you will have option to adjust or change your your data range (as you may observe, you can also use an external data source by choosing the appropriate option) and other options.
  • Clicking ok on this dialog window will open up the Pivot table in a new work sheet (default option) and will show the Pivot Table Fields task pane on the right side. You can drag and drop the fields into Filters, Columns, Rows and Values. 
    • FILTERS: This area contains the fields that enable you to page through the data summaries shown in the pivot table by filtering out sets of data — they act as the filters. For example, if you designate the Year field from a data list as a report filter, you can display data summaries in the pivot table for individual years or for all years represented in the data list.
    • COLUMNS: This area contains the fields that determine the arrangement of data shown in the columns of the pivot table.
    • ROWS: This area contains the fields that determine the arrangement of data shown in the rows of the pivot table.
    • VALUES: This area contains the fields that determine which data are presented in the cells of the pivot table — they are the values that are summarized in its last column (totaled by default).
  • Set these in the way you want and your Pivot table is ready.

To know more about other complex and advanced features of the Pivot Table, check here.

Here is a nice Cheat Sheet containing all the Short Cut keys for Excel. If you are a key board expert, then you will want to check out this as well.