vba - Calling a sub within a loop -


was trying call sub(trialmacro) inside sub(macro2) somehow not activated. there reason why? call function works fine if not within loop. i.e. if plain call function under sub. coding right? i'm not sure if loop disrupts execution

  ' trial macro sub trialmacro() dim prevcell range set prevcell = activecell     solverok setcell:=activecell, maxminval:=2, valueof:="0", bychange:= _        "$m$2,$m$3,$m$5,$m$7"    solversolve userfinish:=true     solverfinish keepfinal:=1     'copy in sample , out of sample error     prevcell.resize(1, 3).copy      'paste values of in sample , out of sample errors     prevcell.offset(0, 4).select     selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _         :=false, transpose:=false      'copy co-efficient     range("m2:m7").select     application.cutcopymode = false     selection.copy      'select paste destination     prevcell.offset(0, 7).select     selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _         :=false, transpose:=true      'copy paste following months data     prevcell.offset(1, -1).resize(12, 1).copy      'select target destination     prevcell.offset(0, 13).select     selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _         :=false, transpose:=true prevcell.offset(1, 0).select end sub  sub macro2() ' ' macro2 macro     dim i, j integer      = 50 162     j = 0 113     sheets("model v2 dubdat >0").cells(i, 17).select     call trialmacro     range("p50:ba50").offset(j, 0).select     application.cutcopymode = false     selection.copy     sheets("reference sheet").select     range("d6").offset(j, 0).select     selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _         :=false, transpose:=false     sheets("model v2 dubdat >0").select     next     next end sub 

give read...

https://msdn.microsoft.com/en-us/library/office/gg251432.aspx

remove call line

call trialmacro 

should be..

trialmacro 

if use call statement subname must followed parentheses.


Comments