How to filter Pivot table based on a cell value - Microsoft Excel

Today I am going to share the VBA code which helps in filtering a pivot table based on cell value in Microsoft Excel.

This method helps you to set a value of cell and then once you click apply the pivot is filtered based on this value.

We will be using cell "C1" as the cell which will store the value to filter "Pivottable1" in the below screenshot. Our data is a 2x2 simple table. Prepare a similar view in your excel sheet with sheet named as "Sheet1".

Once you start excel. hit Alt+F11 and double click on the sheet in which you would like to filter the pivot table.


Now on the right hand side, paste the below code and save the file.

Sub Pivot_filter()
    Application.ScreenUpdating = False
  
    Dim pt1 As PivotTable
    Dim pf1 As PivotField
    
    Set pt1 = Worksheets("Sheet1").PivotTables("PivotTable1")
    Set pf1 = pt1.PivotFields("X")
    
    pf1.CurrentPage = ActiveSheet.Range("C1").Value
    Application.EnableEvents = True

Exit Sub
End Sub

Lets understand the code little more.
  • Application.ScreenUpdating = False: This line ensures the user doesn't see the "real work" code is doing in the backend.
  • Dim pt1 As PivotTable, Dim pf1 As PivotField: Here you are defining the pivottable and pivotfiled objects so that the macro understands them when used later.
  • In the below to lines we are setting the actual names of Pivot Table and the corresponding pivot field which needs to be filtered by the code.
    • Set pt1 = Worksheets("Sheet1").PivotTables("PivotTable1")
    • Set pf1 = pt1.PivotFields("X")
  • pf1.CurrentPage = ActiveSheet.Range("C1").Value: In this line we are pointing the code the cell where it needs to take the value and filter the pivot table.
Thanks for visiting. If you need a copy of the excel file readymade, please email me at askme.kkhelps@gmail.com

How to show values in Millions using custom format - Microsoft Excel

Converting an absolute value to Millions view is task unless you that it is possible to do in a easier way.

Below are two methods:

1. Using concatenation and division.

2. Right click on the value and go to format cells, select custom on left hand side. Now enter #0,"M" in the text box under Type header on right hand side. 

The difference between the first and second method is in the first method the formula bar doesn't show the value instead shpws the formulae used to convert to Millions.

In the second method, the original value is shown as is and doesn't affect user experience.

Additionally, you can use the custom formatting to show text which doesn't show in formula bar like below.

Formula Bar:

Custom Format used: 

Genuine ways to earn money online


I have been stumbling upon people who ask me how to make some extra earnings along with there regular Job. finding a portal which genuinely offers Data entry jobs is very rare. You might fall into a trap. Some basic things to keep in mind while you are looking for online Jobs.

Making money is always good for life. But you need to know the rules of the game.
- If the online job/task requires you to invest in the portal/company then there are high chances that you are about to become a victim of a scam. So do not proceed until you are absolutely sure.

- If you have decided to earn via clicking ads, watching ads, completing online surveys then a single portal will be not meet the ends for you. Hence you need to be active multiple such portals online.

- If you have decided to earn via blogging and content offering, then invest "good and quality" time into your content. Never plagiarize. In this mode, you need to have "lots" of patience as things won't change for a while. It's a snowballing effect and once things start rolling you are in for good earning. Do not publish anything online in a hurry. You need to thoroughly research and present your facts in the right manner so that the person who visits your blog understands it and makes use of it.

- Freelancing. Here you would need to first what is your best skill which you can offer so that people can hire you to do their projects. Topics of freelancing range very widely from data entry, photoshopping, analytics to virtual assistant build, automation, etc.

-Affiliate Marketing: In this method, you would be basically a digital salesman, you would earn a commission every time someone purchases the product you are promoting.

- Online Tutoring. This area is a little Niche and requires you to have a bit of teaching passion. Passion oriented profession and is a crowded market in Online Jobs. The hiring process is a virtual process similar to offline jobs. You would need to Go through the screening and selection cycle.

- Other methods: include doing simple tasks and earning rewards or playing games to earn points that can later be converted to cash etc. Few players in this field are Swagbucks (you earn points whenever you search using their platform), Opinion Outpost


Blogging: You can write/publish content online either using an existing platform like blogger, WordPress, etc which will relieve you from all the pain that goes into hosting and building a website all by yourself. Else you can choose to buy a domain for free (godaddy.com etc) for a specific time period and then build a site according to your taste and so on. But the content is the King here. Your content should be unique and niche as Google will crawl your content and place it at the top if its unique and high quality. Thorough research before publishing will help the reader better and keeps them glued to your website for a longer time.

I decided to review a few sites online and came across the following as "trustable" and with little effort and Patience can bring in the money you are looking for.

Online surveys/Click-to-pay/Watch-Ads

1. ySense:
2. Pay-box
3. Picoworkers
4. Amazon microworkers

Affiliate Marketing:

1. Clickbank


Blogging:

1. Blogger.com
2. Wordpress.com

Freelancing websites:

1. Freelancer
2. Upwork
3. Fiverr

Tutor Jobs: