Create Pivot table with VBA Macro

Поділитися
Вставка
  • Опубліковано 5 лют 2025
  • Create Pivot table with VBA Macro.
    Download Practice File :
    iturninstitute.com/excel_excercise.zip
    Udemy course details:
    1. MS Office Training: www.udemy.com/...
    2. Excel VBA Training: www.udemy.com/...
    3. Excel Training in Hindi: www.udemy.com/...
    4. Excel Training in English: www.udemy.com/...
    Courses in DVD:
    1. Complete Excel (Excel + VBA - Macro) : www.amazon.in/...
    2. Excel VBA - Macro Training: www.amazon.in/...
    3. Excel Training in Hindi: www.amazon.in/...
    4. Excel Training in English: www.amazon.in/...
    Subbscribe to our youtube channel for latest update.
    For Classroom training at Noida: www.iturninstitute.com
    For our Blog: www.learnmiseas...
    Download the app for full training videos and tricks on Excel :
    play.google.co...
    VBA Code:
    Option Explicit
    Sub trail_pivot12()
    Dim mypivot As PivotTable
    Dim mycache As PivotCache
    Sheet3.Activate
    Set mycache = ActiveWorkbook.PivotCaches.Create(xlDatabase, Range("a1").CurrentRegion)
    Sheets.Add , Sheets(Sheets.Count)
    Set mypivot = ActiveSheet.PivotTables.Add(mycache, Range("a4"), "Mypivot1")
    mypivot.PivotFields("Item").Orientation = xlRowField
    mypivot.PivotFields("Client").Orientation = xlColumnField
    mypivot.PivotFields("Sold").Orientation = xlDataField
    End Sub

КОМЕНТАРІ • 75

  • @sakib0072
    @sakib0072 6 років тому +3

    Thanks ! Clean n helpful 😎😎😎

  • @anandusolanki
    @anandusolanki 3 роки тому +4

    Each step of VBA Macro has been present perfectly. Nice Teaching methodology. it really help me a lot.

  • @ggkjghkjh
    @ggkjghkjh Рік тому

    What is the value to be used for filter. Its good that you have mentioned about the row column and data but i need the filter data as well

  • @mehboobmaniyar1890
    @mehboobmaniyar1890 3 роки тому +1

    Really nice explanation

  • @Ksathwik94
    @Ksathwik94 2 місяці тому

    Thank you. Very helpful

  • @neetshil1434
    @neetshil1434 4 роки тому +1

    greate explanation.. its helpful

  • @sanjaynoudiyal9467
    @sanjaynoudiyal9467 5 років тому +2

    Perfect sir. I needed it.. Finally you have done my query... Thanks a lot..

  • @rakshyit
    @rakshyit 11 місяців тому

    Thank you for such a nice explanation. I have a small query. As per the code mentioned by you, I am able to create pivot table, but if I want that table to be sorted in descending order, then how. I tried but it's not working. below is my code.
    Dim datepivot As PivotTable
    Dim datecache As PivotCache
    Sheet2.Activate
    Set datecache = ActiveWorkbook.PivotCaches.Create(xlDatabase, Range("A2").CurrentRegion)
    Set datepivot = ActiveSheet.PivotTables.Add(datecache, Range("b2"), "Mypivot1")
    datepivot.PivotFields("Date").Orientation = xlRowField
    datepivot.PivotFields("Net Premium").Orientation = xlDataField
    datepivot.PivotFields("Net Premium").AutoSort Order:=xlDescending, Field:="Net Premium"
    Last line is the sorting thing, it's not throwing any error, but also not sorting.
    Please help.

  • @manaswinisahoo4555
    @manaswinisahoo4555 4 роки тому +1

    I m your new subscriber
    Very helpful vdo

  • @sheharyarch6317
    @sheharyarch6317 2 роки тому

    Clean n Helpful. Thanks You

  • @makwanamanoj8584
    @makwanamanoj8584 3 роки тому

    Really helpful...nice and best content

  • @velperumal6986
    @velperumal6986 3 роки тому +1

    HI Bro, Run Time Error 1004 'Unable to get the PivotFields property of the PivotTable class', How to fix this error

  • @shimonatiwari9954
    @shimonatiwari9954 Рік тому

    Hi, this is the best and easy pivot option I have ever seen..just want your little help I want to add a command of sorting the data from largest to smallest number in pivot..is that possible?

  • @ganeshgaikwad8810
    @ganeshgaikwad8810 3 роки тому

    Hi sir i want to know how to change the value like sum or count in xldatafield

  • @Ramyadav-tv1rz
    @Ramyadav-tv1rz 2 роки тому

    Really very nice and useful. Thanks you very much for such video !

  • @1431jagan
    @1431jagan 2 роки тому +1

    Hi Himanshu i tried using same code in VBA it is showing error as "Invalid procedure call or Argument"

  • @deb1995
    @deb1995 Рік тому

    it is showing as compile error : variable not defined in the sub trail_pivot12() line

  • @merugubhanu3334
    @merugubhanu3334 Рік тому

    I wanted to create the data in specific worksheet how can we do that

  • @indiangraphics1111
    @indiangraphics1111 4 роки тому +1

    fantastic job bro

  • @satishchaurasia84ya
    @satishchaurasia84ya 4 роки тому +1

    Woow perfect nice way of teaching. Thank you so much keep it up

  • @a.b.c.0.2
    @a.b.c.0.2 4 роки тому

    Thanks for this video, this video is easy to learn and understand micro.

  • @rakeshjoshi766
    @rakeshjoshi766 4 роки тому +1

    Hello, when i am using this code i am unable to do create pivot table, just adding a sheet after run the macro. Plz suggest.

    • @trainingbyhimanshu
      @trainingbyhimanshu  4 роки тому

      What's the error you are getting

    • @rakeshjoshi766
      @rakeshjoshi766 4 роки тому

      @@trainingbyhimanshu - first i create a button then use your code Dim mypivot.................. to
      Set mypivot =............ "Mypivot1")
      After use this code nothing is happened only create new sheet.

  • @shaikhaziz9703
    @shaikhaziz9703 4 роки тому +1

    Dear Sir, Please help me to find out below solution,
    what if i want to start my pivot table from second row because first row is merged i want to start my pivot from second row..according to your code i have tried to changed mycache range from ("A1") to ("A2")...it's not working...please help

  • @srivatsaniyer8948
    @srivatsaniyer8948 2 роки тому

    How to add more pivots in same worksheet

  • @giteshbhoir9086
    @giteshbhoir9086 3 роки тому

    Thank you !! helpful

  • @chhinuchhuria9347
    @chhinuchhuria9347 Рік тому

    Thanks sir

  • @sureshjogi9626
    @sureshjogi9626 6 років тому

    very good explanation and useful for learning VBA users and thanks

  • @swaroopsinha9648
    @swaroopsinha9648 4 роки тому +1

    Sir, first of all thank you for sharing this, I have went through many video on this topic but your video was really simple but exactly what anyone can learn,, simply amazing,, sir if you teaching macro then I would love to learn please let me know.. And also can you help me with putting filter on the pivot i.e. above to the xlrow.. Many thanks sir

    • @trainingbyhimanshu
      @trainingbyhimanshu  4 роки тому +1

      Thank you Swaroop. Very soon video will come stay connected

  • @arsidagamer
    @arsidagamer 2 роки тому

    How can i do max of items instead of sum in the same code?

  • @shreeyasingh6359
    @shreeyasingh6359 5 років тому

    Can you please mention the syntax for creating pivot in an existing sheet

    • @mrandmrscooking206
      @mrandmrscooking206 5 років тому

      Don't type sheets.add command.. rather while setting mypivot give the cell reference where you want to create pivot table

  • @sandyk3264
    @sandyk3264 4 роки тому

    Is it pssbl to filter only one item, ignoring other. Being evertime i need to shoose same filtr but other keep changing. So, if i mention them in vba it will give error nxt time.

    • @trainingbyhimanshu
      @trainingbyhimanshu  4 роки тому

      Your question not clear. You mean to say filter through VBA in Pivot.

    • @sandyk3264
      @sandyk3264 4 роки тому

      Training by Himanshu: yes. My only one item is fixed evertime in data, but i need to deselct lots of others, to select that one item. Ex: 4 items, a,b,c &d. I need to put true for a, and false for other 3.

  • @nileshghanate3377
    @nileshghanate3377 7 років тому

    Very nice video.. Explanation is in very simple language, easy to understand. I am expecting more useful videos on some advanced level coding.

  • @gsc221315
    @gsc221315 4 роки тому +1

    The code is running fine in Module but not in Command Button ..why so ?

    • @trainingbyhimanshu
      @trainingbyhimanshu  4 роки тому

      Command button also need to be coded. Watch the video carefully

  • @shivkumar3435
    @shivkumar3435 3 роки тому

    Kya age factor h Vba me job ke liye. 30 ke par wale ke liye h.

  • @abhishekkommera8965
    @abhishekkommera8965 4 роки тому +1

    getting error type mismatch "13" in set mycache

  • @ghazikhan3133
    @ghazikhan3133 5 років тому +1

    How to code it if you want to create the pivot in existing sheet?

    • @trainingbyhimanshu
      @trainingbyhimanshu  5 років тому +1

      Rather then sheets.add line type the sheet reference where you want to create pivot table...

    • @ghazikhan3133
      @ghazikhan3133 5 років тому

      @@trainingbyhimanshu thanks a lot btw my colleagues are getting error at (wdformatrichtext) step, are they missing any set up in there excel or outlook for version 2010 and 2016. How should I fix it.. please help

    • @trainingbyhimanshu
      @trainingbyhimanshu  5 років тому

      @@ghazikhan3133 clarify.. not getting

    • @ghazikhan3133
      @ghazikhan3133 5 років тому

      @@trainingbyhimanshu sorry this was not related to this video

  • @aroraankit873
    @aroraankit873 4 роки тому

    Getting Run-Time error 1004 unable to get the current region property of the range class

  • @tarunsingh7107
    @tarunsingh7107 4 роки тому

    It is giving error of type match in mycatche pls help

  • @nehakharche6752
    @nehakharche6752 3 роки тому

    Getting 1004 error we can't change this part of the pivot table

  • @paddyp8546
    @paddyp8546 3 роки тому

    Showing error at Set mycache line

  • @saiprakashpawar133
    @saiprakashpawar133 7 років тому

    Hi Sir
    This is really good Video, Thank you:-)

  • @allaboutvideos5472
    @allaboutvideos5472 6 років тому

    Nicely explained☺

  • @sanjeevsingh1489
    @sanjeevsingh1489 5 років тому

    Thanks

  • @AshwaniKumarshakya
    @AshwaniKumarshakya 6 років тому

    Code not working in another file
    Repeated in same file

  • @user-ix9hb7je4lGaurav
    @user-ix9hb7je4lGaurav 4 роки тому

    It’s showing me mismatch 13 error

  • @faltooo3446
    @faltooo3446 5 років тому

    CODE NOT WORK PROPERLY .