Excel Macro - Pivot Table, Dynamic Range, Error Handling - Excel VBA Part 11

Поділитися
Вставка
  • Опубліковано 10 лют 2025

КОМЕНТАРІ • 126

  • @Kurkess
    @Kurkess 4 роки тому +21

    This is the best explanation to creating a pivot table from Dynamic Range I've been able to find. So many unnecessary complications on some of the other websites and videos. Thanks man.

  • @ashleynewberry698
    @ashleynewberry698 3 роки тому +5

    I have been struggling with this issue for way too long than I care to admit. Thank you so much for explaining it in simple terms and not trying to make it complicated.

  • @jeetcaresforyou3221
    @jeetcaresforyou3221 6 місяців тому +2

    Dude, you solved my long time problem in minutes, I was desperately looking for this video, Thanks a ton.

  • @nazarkamal8831
    @nazarkamal8831 Рік тому +1

    Atlast I found the correct UA-cam channel for What I exactly want

  • @SabOnlineHai
    @SabOnlineHai 3 місяці тому

    finally I found the correct UA-cam channel. best explanation to creating a pivot table from Dynamic Range. Thank You Soo much..man

  • @michaellawton6918
    @michaellawton6918 4 роки тому +2

    I was getting very frustrated trying to create a Pivot table by recording. This worked perfectly. Thank you.

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

    You just fixed a problem I gave up on yesterday by doing what I wouldn't advise anyone to do in coding. Thanks, you are a blessing !!!

  • @jdub4245
    @jdub4245 Рік тому +1

    Awesome tutorial, thank you for taking the time and sharing!

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

    Excellent explanation. Wish I saw this video first. Would of saved me hours trying to find the answer.

  • @evandixon1990
    @evandixon1990 3 роки тому +2

    You Sire are a Legend and a Scholar! Thank you!

  • @srinivasannarayanaswami5378
    @srinivasannarayanaswami5378 4 роки тому +2

    Simply Awesome....loved it. Thanks a lot for this lucid tutorial!

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

    Thank you. Your explanation was clear and this helped me complete the macro without giving up.

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

    The best video so far....Hope to learn more from you. Thank you so much

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

    This is very workable pivot macro! Thank you.

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

    Amazing explaination. Simple and easy to grab. :) Thank you so much for sharing.

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

    excellent explanation

  • @deepanshitayal4534
    @deepanshitayal4534 4 роки тому +2

    This trick worked! Thank you for the video!

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

    Thanks Super. I really happy to see this type of videos

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

    This is what I exactly 💯 want without unwanted things !!! How to auto genarate pivot VBA excel macro thanks man

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

    Thank you for detailed steps

  • @Dexter_1012
    @Dexter_1012 9 місяців тому

    This helped! Thanks a lot for making this video !!! :)

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

    This video was really helpful. Thanks buddy !

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

    Excellent training. Good job!

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

    you are a legend Sir! thanks for the easy example

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

    You are a god, thank you so much

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

    Quite helpful. Thankyou ! for sharing

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

    Man, you are awsomeee, do more of those plz.

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

    Bro! I just love you 😘😘😘😘😘😘😘

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

    Thanks for sharing.

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

    Thank u sir
    You information is very helpfull for my job👍

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

    Thank you so much for this video!

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

    Thanks, Great Help 💻💻 Best Explaination

  • @luisochoa3588
    @luisochoa3588 Рік тому +1

    Thanks a lot man, this is the best explanation I watched and helped me a lot. I only have a question about; it could be possible associate the datasource to a the active sheet in the book that somene is using no matter the names of the others sheets. I mean, is it possible to execute the same macro in every workbook's sheet?

  • @carlie0827
    @carlie0827 8 місяців тому

    You saved my career

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

    Thank you! You are a genius!!!!!!!!!!

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

    Very informative & helpful. Just wanted to know why I am not able to run the micro if i do the pivot on the same worksheet? What changes need to be made?

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

    Thank you for sharing this truly useful video. 👏 🌟 🌟

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

    Great video, I'm glad I have found this channel.
    I have a couple of questions :
    What if we had already an existent sheet where we want to place the pivot table ? What should we change in this case ?
    What do we do to stop the macro from creating several sheets with the same outcome every time we execute this code ?

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

    Thanks!

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

    Good!

  • @akhileshreddy0910
    @akhileshreddy0910 Рік тому +1

    When ever i add variable as pivotws & "!R3C1"
    It is throwing an error as invalid procedure call or argument (error 5)
    Please give me a solution for it 4:23
    Whenever I use concatenation it is giving the error

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

    Thanks for the video and information! Is there a way to use last row and last column as the pivot table range?

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

    Great Video and tutorial good sir! You've taught me how to understand VBA. But I have a question, How do I make column range dynamic as well?

  • @user-zt8kk3ys9v
    @user-zt8kk3ys9v 4 роки тому +1

    amazing

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

    Ater hours of searching, found all I need in this video. But one last thing, is there a way I could get the additional columns of data I add? Like you did to get additional rows of data you added

  • @Mr.IvanMiller
    @Mr.IvanMiller Рік тому

    What do I do if I need to create multiple Pivot Tables within the same worksheet? Do I have to rename the 'pivotWS' for each pivot table? (ie., pivotWS1 for the first pivot table and then pivotWS2 for another one?

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

    Thank for this informative video. Could you explain what to do if the field is the same for column area as well as the Value area?
    because then, it only considers the field in the value area and continues to run the subroutine.

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

      If you move .AddDataField line above .PivotFields with blocks, it should fix your problem.

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

    Sir, would you kindly make a video on "How to split number and text from an Alphanumeric String through VBA UDF?"

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

      Power Query has a build-in solution for this. Does it have to be VBA?

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

      @@ExcelGoogleSheets Sir, I've been your subscribers for years. Please make a video on this topic.
      Yes sir, it has to be through VBA. Because we are working on office 2007. So there is no Power Query and PowerPivot.

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

      Check this out stackoverflow.com/questions/48513694/excel-vba-split-numbers-and-text-from-a-string-into-columns

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

    what can i do if i wants to create pivot table on the same sheet where my database is

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

    Please help. In your video yiu have told how to take data upto the last row. I need to know how can we take data upto the last second row of data. How to work it out in VBA. Please reply.

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

    Thanks for the information, just wanted to know, if i want to name the output tab any specific other than "sheet 2", how can i do that? Also will it work for multiple pivots in different tabs from sheet 1 in same sheet?
    Thanks in advance!

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

      Add
      activesheet.name = "New Name"
      by the end of the code
      and yes.

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

    Thanks for this video, how to change the Pivot sheet name

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

    love you

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

    Hey! Is there any way to make pivot table by dynamic column... You shows dynamic rows...plz tell me dynamic column also

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

    The explanation is good. I have tried this in my computer and it works fine. But I have a doubt. How does it not through an error as the variable is not declared?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  4 роки тому +2

      It will only force you to declare variables if you have Option Explicit on top.

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

    Pivot in same worksheet - I have recorded the macro placing the pivot table in the same worksheet - however when I rerun the macro it stops at the following point:
    Range("V2").Select
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Table1", Version:=6).CreatePivotTable TableDestination:= _
    "New Hires_SAP_KDVS02!R2C22", TableName:="PivotTable3", DefaultVersion:=6
    How can I fix this?

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

    Text values in value field gets converted to number.. But i want it to remain as text... I have recorded it by adding data model and using ConcateneX but this doesn't work for other sheets.
    Could u please tell how to add datamodel and give text in pivot table value filed.

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

    Getting a message that the macro cannot run in break mode. What is it?

  • @AmanKumar-ps2pg
    @AmanKumar-ps2pg 2 роки тому

    Hi, I am getting "Compile Error : Variable not defined", when I add pivotWS variable. Do I need to change some setting?

    • @AmanKumar-ps2pg
      @AmanKumar-ps2pg 2 роки тому

      I was using Open Explicit. Removing that solved it.

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

    Hi Brother, My code shows error when I change to "'" & dataWS & "'!A1:F" Could you please help ???

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

    I have a Master data sales report . I slice the data into separate worksheets by customer name wise. The number of rows on each sheet vary depending upon data each month. I need a macro to create a pivot table at the bottom of the data on each sheet for further working. I tried after watching this video but it's not working. Please help

  • @BGLee-rh8sh
    @BGLee-rh8sh Рік тому

    How can I create Macro If i need filter the data?

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

    It's easy when the header of table no change..
    How if the header change?

  • @KK-mf6su
    @KK-mf6su 2 роки тому

    Sir, it occur a “424” error (object required), in debugger, it highlighting “lr=Cells(Row.Court. 1).End(xlUp).Row”, how can I solve it? Thank you.

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

    I’m facing an issue where I’m in the middle of recording a macro with pivot table and when I click the “Do Not Show Subtotals” button under Design tab, where’s an error pops up saying “unable to record”. Is there anyway to solve this? Thanks

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

      Try adding this step manually instead of recording,
      Dim PvtTbl As PivotTable
      Dim pvtFld As PivotField
      Set PvtTbl = ActiveSheet.PivotTables(1)
      'hide Subtotals for all fields in the PivotTable .
      With PvtTbl
      For Each pvtFld In .PivotFields
      pvtFld.Subtotals(1) = True
      pvtFld.Subtotals(1) = False
      Next pvtFld
      End With

  • @NehaSharma-pr3ms
    @NehaSharma-pr3ms 4 роки тому +1

    Facing issues while specifying the source data from R1C1 syntax to regular syntax , throwing me pivot table field name is not valid

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

      Make sure you include headers in your range and there should be no blanks or duplicate names in headers.

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

      @@ExcelGoogleSheets I'm having the same issue, but I made sure the format was exactly like what you did in your video. Any help would be greatly appreciated!

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

    huh complex explanation

  • @gurunathan-ed3yx
    @gurunathan-ed3yx 3 роки тому

    I followed the same as you have told in this video but I was getting a error stating "cant execute code in break mode"

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

      Hit "reset" button. Same as stop button on old players.

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

      @@ExcelGoogleSheets I got same error and fixed by reset button
      thanks a lot

  • @hellostranger5417
    @hellostranger5417 5 місяців тому

    Bro You missed to tell how the last column code works, as for my data column increases

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

    why does it seems that you can assign var right away, while me need to declare it first ? like 'dim Name As String' ??

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

      If you remove "option explicit" on top then you won't have to declare the variables.

  • @praveenchauhandilse..166
    @praveenchauhandilse..166 4 роки тому

    Hey, after giving pivotWS as activesheet name, still getting error, "Can't execute code in breaking mode"?

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

    Hi, when i write: TableDestination _
    := pivotWS&"!R3C1" I get Compile error Expected: end of statement. Could somebody help here?

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

      try adding a space before and after &

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

      @@ExcelGoogleSheets thanks, I did. but have got another kind of error for the last line in this code: ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
      "08.04.2022 (2)!R1C1:R19C9", Version:=6).CreatePivotTable TableDestination _
      :=pivotWS & "!R3C1", TableName:="PivotTable1", DefaultVersion:=6

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

      @@annapetmikel4356 You didn't update SourceData like mentioned in the video.

  • @RakeshKumar-df3sg
    @RakeshKumar-df3sg Рік тому

    I am getting error as Cannot execute code in break mode. Please help

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

    Thanks for the video. Can I add a name to the new worksheet?

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

    It is not working for me.I changed the name from Sheet2 to PivotWS as per the video,bt it didnt work out,I am using excel 2013.Please let me know any other solution.
    I need this urgently.

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

    Mine says can't execute in break mode. Help

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

    I literally cannot get this to work

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

    Hi This is not worked in office 365

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

      It works fine in office 365 so long as you are not using the web browser version.

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

    i got error after following ur steps

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

      it gives me error when i try to use A1 and F22 formula

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

    I followed step by step, when I added lr and tested the Macro, I get the error '1004' saying Pivottable Field name not valid. Here is code:
    Sub PivotEmployeesPriojectTask()
    '
    ' PivotEmployeesPriojectTask Macro
    ' Pivot employees on project-task by earnings period end date.
    '
    '
    lr = Cells(Rows.Count, 1).End(xlUp).Row

    Sheets.Add
    pivotWS = ActiveSheet.Name

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Salary-Fringe Combined_1!A1:BO" & lr, Version:=6).CreatePivotTable _
    TableDestination:=pivotWS & "!R3C1", TableName:="PivotTable1", _
    DefaultVersion:=6
    Sheets(pivotWS).Select
    Cells(3, 1).Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("CCOA TASK Code")
    .Orientation = xlRowField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Employee Name")
    .Orientation = xlRowField
    .Position = 2
    End With
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Employee ID")
    .Orientation = xlRowField
    .Position = 3
    End With
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Transaction Type")
    .Orientation = xlRowField
    .Position = 4
    End With
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Journal Template Code" _
    )
    .Orientation = xlRowField
    .Position = 5
    End With
    With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
    "Earnings Period End Date")
    .Orientation = xlColumnField
    .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Earnings Period End Date"). _
    AutoGroup
    ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
    "PivotTable1").PivotFields("Monetary Amount"), "Sum of Monetary Amount", xlSum
    Range("B8").Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
    "Sum of Monetary Amount")
    .NumberFormat = "$#,##0.00"
    End With
    End Sub

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

      Any help on this would be greatly appreciated!

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

      Which line is highlighted in yellow when you get this error?

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

    Thanks!