excel - Error 13 Type mismatch and Error 9 Script out of range -
I created a similar macro to generate pivot tables and charts, and it worked fine. Now let me create a new one. Is required, so I applied the same code, but accordingly amended it. But this time, VBA told me that I have error 9 'script is out, and sometimes error 13' type mismatch after I execute the code. I repeated the code several times, but sometimes this error was given 13, sometimes it got 9 error. That's why I am confused. This is almost the code that worked for my last job. I am thinking that a person can tell the place where I am wrong. I appreciate it. Thanks!
Diff_Milg () Dynamic Range Dim Range as SourceRange ObjField PivotField Dim ObjPivot PivotTable Dim LastRow Range DimLRRng as Range Dim GRng as Range LastRow = Cells (Rows.Count, As 1) .end (xlDown) .Row Sheet ("Sheet1") Select Set SourceRange = Sheet ("Sheet1") Range ("A2: D" .. & LastRow) After Sheets.Add: = Sheet (Sheets.Count) ActiveSheet .Name = "Various Milg" ActiveWorkbook.PivotCaches.Add (_ SourceType: = xlDatabase, _ SourceData: = SourceRange) .CreatePivotTable _ TableDestination: Sheet ("Various Milg") range ("A1 "), _ TableName :. = "Different mileage", _ DefaultVersion: = xlPivotTableVersion11 * error here ActiveSheet.PivotTableWizard TableDestination: = ActiveSheet.Cells (1, ActiveSheet.PivotTables ( "different mileage with 1)") PivotFields ( "ProductionYM") .Orientation = xlRowField .. With ActiveSheet.PivotTables ("Different Mileage") with status = 1 termination. PivotFields ("Milg") .Articles = xlColumnField .Position = 1 End ActiveSheet.PivotT with ables ("various mileage") along with. PivotFields ("FailPartId") .Orientation = xlDataField .Name = "CountofMilg" .Function = xlCount.Status = 1 set with objPivot = ActiveSheet.PivotTables ("various mileage") set range area label whose items are divided Are: set lblRng = objPivot.PivotFields ("Milg") LabelRange lblRng.Group Start:. = 0, By: = 36000, By: = 5000 'Ungrouping: Set to set' lblRng.Ungroup 'set range, grRng = objPivot.PivotFields ("ProductionYM"). DataRange
Comments
Post a Comment