excel - Open Selected Pivot Detail or create new sheet -
i need vba code open pivot field's details on new page or if field not found in pivot table, create new sheet named field supposed named. keep getting compile error: end if without block if missing?? have far:
sub macro6 sheets("sheet4").select columns("a:a").select set found = cells.find(what:="+ deposit", after:=cells(1, 1), lookat:=xlpart, searchorder:=xlbycolumns, searchdirection:=xlnext) if = found.address range(a).select activecell.offset(0, 3).select selection.showdetail = true sheets("sheet5").name = "deposits" else: sheets.add after:=sheets(sheets.count) sheets("sheet5").name = "deposits" end if sheets("sheet4").select columns("a:a").select set found = cells.find(what:="- withdrawal", after:=cells(1, 1), lookat:=xlpart, searchorder:=xlbycolumns, searchdirection:=xlnext) if = found.address range(a).select activecell.offset(0, 3).select selection.showdetail = true sheets("sheet6").name = "withdrawals" else: sheets.add after:=sheets(sheets.count) sheets("sheet6").name = "withdrawals" end if sheets("sheet4").select columns("a:a").select set found = cells.find(what:="- check", after:=cells(1, 1), lookat:=xlpart, searchorder:=xlbycolumns, searchdirection:=xlnext) if = found.address range(a).select activecell.offset(0, 3).select selection.showdetail = true sheets("sheet7").name = "checks" else: sheets.add after:=sheets(sheets.count) sheets("sheet7").name = "checks" end if end sub
sub macro10() ' ' macro10 macro ' sheets("sheet4").select range("a4").select set found = cells.find(what:="+ deposit", after:=cells(1, 1), lookat:=xlpart, searchorder:=xlbycolumns, searchdirection:=xlnext) on error goto nodeposit = found.address range(a).select activecell.offset(0, 3).select selection.showdetail = true withdrawals: sheets("sheet4").select range("a4").select set found = cells.find(what:="- withdrawal", after:=cells(1, 1), lookat:=xlpart, searchorder:=xlbycolumns, searchdirection:=xlnext) on error goto nowithdrawal = found.address range(a).select activecell.offset(0, 3).select selection.showdetail = true checks: sheets("sheet4").select range("a4").select set found = cells.find(what:="- check", after:=cells(1, 1), lookat:=xlpart, searchorder:=xlbycolumns, searchdirection:=xlnext) on error goto nocheck = found.address range(a).select activecell.offset(0, 3).select selection.showdetail = true labels: sheets("sheet5").name = "deposits" sheets("sheet6").name = "withdrawals" sheets("sheet7").name = "checks" exit sub nodeposit: sheets.add after:=sheets(sheets.count) resume withdrawals: nowithdrawal: sheets.add after:=sheets(sheets.count) resume checks: nocheck: sheets.add after:=sheets(sheets.count) resume labels: end sub
Comments
Post a Comment