excel - This macro is giving me error after creating pivot table? -


when run macro goes perfect upto line 143. adds pivot table in sheet, gives

error 13, type mismatch.

i not programming guy. recorded macro , edited more hour searching on internet. think here help.

sub macro9() ' macro1 macro     dim lr long     dim pcache pivotcache     dim ptable pivottable      lr = cells(activesheet.rows.count, 1).end(xlup).row      dim prange range     set prange = range(cells(1, 1), cells(lr, 5))      columns("e:e").select     selection.insert shift:=xltoright, copyorigin:=xlformatfromleftorabove      range("e1").select     activecell.formular1c1 = "decimal"      range("e2").select     activecell.formular1c1 = "=rc[-1]*24"      range("e2").select     selection.copy      range(cells(lr, 5), cells(2, 5)).select     activesheet.paste      application.cutcopymode = false     selection.numberformat = "general"      range("a1").select     range(selection, selection.end(xltoright)).select     range(selection, selection.end(xldown)).select      selection.borders(xldiagonaldown).linestyle = xlnone     selection.borders(xldiagonalup).linestyle = xlnone     selection.borders(xledgeleft)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xledgetop)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xledgebottom)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xledgeright)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xlinsidevertical)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xlinsidehorizontal)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xldiagonaldown).linestyle = xlnone     selection.borders(xldiagonalup).linestyle = xlnone     selection.borders(xledgeleft)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xledgetop)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xledgebottom)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xledgeright)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xlinsidevertical)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xlinsidehorizontal)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end      range("a1:f1").select     selection.borders(xldiagonaldown).linestyle = xlnone     selection.borders(xldiagonalup).linestyle = xlnone     selection.borders(xledgeleft)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xledgetop)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xledgebottom)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xledgeright)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlmedium     end     selection.borders(xlinsidevertical)         .linestyle = xlcontinuous         .colorindex = 0         .tintandshade = 0         .weight = xlthin     end     selection.borders(xlinsidehorizontal).linestyle = xlnone     columns("f:f").entirecolumn.autofit      range("h2").select     set pcache = activeworkbook.pivotcaches.create _       (sourcetype:=xldatabase, sourcedata:=prange). _       createpivottable(tabledestination:=activesheet.cells(2, 8), _       tablename:="pivottable")      cells(2, 8).select     activesheet.pivottables("pivottable1").pivotfields("activity")         .orientation = xlrowfield         .position = 1     end     activesheet.pivottables("pivottable1").adddatafield activesheet.pivottables( _         "pivottable1").pivotfields("decimal"), "sum of decimal", xlsum     activeworkbook.showpivottablefieldlist = false end sub 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -