vba - Excel macro to pick a number corresponding to a cell value and insert same number of rows -
i new macros , trying create macros lack of syntactical knowledge posing big hurdle, tried recording become mcro specific case only. objective create macro first goes cell f1 of sheet2 , find content(say 'a') , gets value in cell g1 of sheet2 , in sheet1 search value 'a' let in cell k23 of sheet1 , inserts number of rows corresponding sheet2 g1 below k23 , goes , searches f2 , repeats process many values there in column f. when inserts rows in sheet1 column d of these blanks rows should different values values should same 23rd row. tried doing using recording , macro attached below, case specific. here sheet2 pivots , sheet1 team master.
sub macro3() ' ' macro3 macro ' ' sheets("pivots").select workbooks("target macro.xlsm").connections.add2 _ "worksheetconnection_team master!$a$1:$l$200", "", _ "worksheet;d:\[target macro.xlsm]team master", "team master!$a$1:$l$200", 7, _ true, false activeworkbook.pivotcaches.create(sourcetype:=xlexternal, sourcedata:= _ activeworkbook.connections("worksheetconnection_team master!$a$1:$l$200"), _ version:=xlpivottableversion15).createpivottable tabledestination:= _ "pivots!r1c1", tablename:="pivottable9", defaultversion:= _ xlpivottableversion15 cells(1, 1).select activesheet.pivottables("pivottable9").cubefields("[range].[tl name]") .orientation = xlrowfield .position = 1 end activesheet.pivottables("pivottable9").cubefields.getmeasure _ "[range].[kam mobile]", xlcount, "count of kam mobile" activesheet.pivottables("pivottable9").adddatafield activesheet.pivottables( _ "pivottable9").cubefields("[measures].[count of kam mobile]"), _ "count of kam mobile" range("a2").select range(selection, selection.end(xldown)).select range("a2:b40").select selection.copy range("f1").select activesheet.paste range("a1:b1").select range(selection, selection.end(xldown)).select range("b26").select selection.end(xlup).select selection.end(xltoleft).select range("a1:b1").select range(selection, selection.end(xldown)).select application.cutcopymode = false selection.clearcontents activeworkbook.connections("worksheetconnection_team master!$a$1:$l$200"). _ delete range("g1").select selection.autofilter selection.autofilter range("f1").select selection.entirerow.insert activecell.formular1c1 = "tl" range("g1").select activecell.formular1c1 = "count" range("g1").select selection.autofilter activesheet.range("$f$1:$g$40").autofilter field:=2, criteria1:=">=4", _ operator:=xland range("g3").select range(selection, selection.end(xldown)).select selection.entirerow.delete range("g1").select selection.autofilter range("f2").select selection.copy sheets("team master").select selection.find(what:="9826212153", after:=activecell, lookin:=xlformulas _ , lookat:=xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, _ matchcase:=false, searchformat:=false).activate range("g112").select end sub
Comments
Post a Comment