Hi,
I just joined this forum and I am only at beginner level with VB for Excel. I am looking for help to learn how to set up a loop to do something that I have already created a macro to do am looking for a way to make the coding more efficient and condensed. The existing macro looks like this:
Range("AM8").GoalSeek Goal:=0, ChangingCell:=Range("Y30")
Range("AM9").GoalSeek Goal:=0, ChangingCell:=Range("Y31")
Range("AM10").GoalSeek Goal:=0, ChangingCell:=Range("Y32")
Range("AM11").GoalSeek Goal:=0, ChangingCell:=Range("Y33")
Range("AM12").GoalSeek Goal:=0, ChangingCell:=Range("Y34")
Range("AM13").GoalSeek Goal:=0, ChangingCell:=Range("Y35")
Range("AM14").GoalSeek Goal:=0, ChangingCell:=Range("Y36")
Range("AM15").GoalSeek Goal:=0, ChangingCell:=Range("Y37")
Range("AM16").GoalSeek Goal:=0, ChangingCell:=Range("Y38")
Range("AM17").GoalSeek Goal:=0, ChangingCell:=Range("Y39")
Range("AM18").GoalSeek Goal:=0, ChangingCell:=Range("Y40")
Range("AM19").GoalSeek Goal:=0, ChangingCell:=Range("Y41")
Range("AM20").GoalSeek Goal:=0, ChangingCell:=Range("Y42")
Range("AM21").GoalSeek Goal:=0, ChangingCell:=Range("Y43")
Range("AM22").GoalSeek Goal:=0, ChangingCell:=Range("Y44")
Range("AM23").GoalSeek Goal:=0, ChangingCell:=Range("Y45")
Range("AM24").GoalSeek Goal:=0, ChangingCell:=Range("Y46")
Range("AM25").GoalSeek Goal:=0, ChangingCell:=Range("Y47")
Range("AN8").GoalSeek Goal:=0, ChangingCell:=Range("Z30")
Range("AN9").GoalSeek Goal:=0, ChangingCell:=Range("Z31")
Range("AN10").GoalSeek Goal:=0, ChangingCell:=Range("Z32")
Range("AN11").GoalSeek Goal:=0, ChangingCell:=Range("Z33")
Range("AN12").GoalSeek Goal:=0, ChangingCell:=Range("Z34")
Range("AN13").GoalSeek Goal:=0, ChangingCell:=Range("Z35")
Range("AN14").GoalSeek Goal:=0, ChangingCell:=Range("Z36")
Range("AN15").GoalSeek Goal:=0, ChangingCell:=Range("Z37")
Range("AN16").GoalSeek Goal:=0, ChangingCell:=Range("Z38")
Range("AN17").GoalSeek Goal:=0, ChangingCell:=Range("Z39")
Range("AN18").GoalSeek Goal:=0, ChangingCell:=Range("Z40")
Range("AN19").GoalSeek Goal:=0, ChangingCell:=Range("Z41")
Range("AN20").GoalSeek Goal:=0, ChangingCell:=Range("Z42")
Range("AN21").GoalSeek Goal:=0, ChangingCell:=Range("Z43")
Range("AN22").GoalSeek Goal:=0, ChangingCell:=Range("Z44")
Range("AN23").GoalSeek Goal:=0, ChangingCell:=Range("Z45")
Range("AN24").GoalSeek Goal:=0, ChangingCell:=Range("Z46")
Range("AN25").GoalSeek Goal:=0, ChangingCell:=Range("Z47")
Range("AO8").GoalSeek Goal:=0, ChangingCell:=Range("AA30")
Range("AO9").GoalSeek Goal:=0, ChangingCell:=Range("AA31")
Range("AO10").GoalSeek Goal:=0, ChangingCell:=Range("AA32")
Range("AO11").GoalSeek Goal:=0, ChangingCell:=Range("AA33")
Range("AO12").GoalSeek Goal:=0, ChangingCell:=Range("AA34")
Range("AO13").GoalSeek Goal:=0, ChangingCell:=Range("AA35")
Range("AO14").GoalSeek Goal:=0, ChangingCell:=Range("AA36")
Range("AO15").GoalSeek Goal:=0, ChangingCell:=Range("AA37")
Range("AO16").GoalSeek Goal:=0, ChangingCell:=Range("AA38")
Range("AO17").GoalSeek Goal:=0, ChangingCell:=Range("AA39")
Range("AO18").GoalSeek Goal:=0, ChangingCell:=Range("AA40")
Range("AO19").GoalSeek Goal:=0, ChangingCell:=Range("AA41")
Range("AO20").GoalSeek Goal:=0, ChangingCell:=Range("AA42")
Range("AO21").GoalSeek Goal:=0, ChangingCell:=Range("AA43")
Range("AO22").GoalSeek Goal:=0, ChangingCell:=Range("AA44")
Range("AO23").GoalSeek Goal:=0, ChangingCell:=Range("AA45")
Range("AO24").GoalSeek Goal:=0, ChangingCell:=Range("AA46")
Range("AO25").GoalSeek Goal:=0, ChangingCell:=Range("AA47")
Range("AP8").GoalSeek Goal:=0, ChangingCell:=Range("AB30")
Range("AP9").GoalSeek Goal:=0, ChangingCell:=Range("AB31")
Range("AP10").GoalSeek Goal:=0, ChangingCell:=Range("AB32")
Range("AP11").GoalSeek Goal:=0, ChangingCell:=Range("AB33")
Range("AP12").GoalSeek Goal:=0, ChangingCell:=Range("AB34")
Range("AP13").GoalSeek Goal:=0, ChangingCell:=Range("AB35")
Range("AP14").GoalSeek Goal:=0, ChangingCell:=Range("AB36")
Range("AP15").GoalSeek Goal:=0, ChangingCell:=Range("AB37")
Range("AP16").GoalSeek Goal:=0, ChangingCell:=Range("AB38")
Range("AP17").GoalSeek Goal:=0, ChangingCell:=Range("AB39")
Range("AP18").GoalSeek Goal:=0, ChangingCell:=Range("AB40")
Range("AP19").GoalSeek Goal:=0, ChangingCell:=Range("AB41")
Range("AP20").GoalSeek Goal:=0, ChangingCell:=Range("AB42")
Range("AP21").GoalSeek Goal:=0, ChangingCell:=Range("AB43")
Range("AP22").GoalSeek Goal:=0, ChangingCell:=Range("AB44")
Range("AP23").GoalSeek Goal:=0, ChangingCell:=Range("AB45")
Range("AP24").GoalSeek Goal:=0, ChangingCell:=Range("AB46")
Range("AP25").GoalSeek Goal:=0, ChangingCell:=Range("AB47")
Range("AQ8").GoalSeek Goal:=0, ChangingCell:=Range("AC30")
Range("AQ9").GoalSeek Goal:=0, ChangingCell:=Range("AC31")
Range("AQ10").GoalSeek Goal:=0, ChangingCell:=Range("AC32")
Range("AQ11").GoalSeek Goal:=0, ChangingCell:=Range("AC33")
Range("AQ12").GoalSeek Goal:=0, ChangingCell:=Range("AC34")
Range("AQ13").GoalSeek Goal:=0, ChangingCell:=Range("AC35")
Range("AQ14").GoalSeek Goal:=0, ChangingCell:=Range("AC36")
Range("AQ15").GoalSeek Goal:=0, ChangingCell:=Range("AC37")
Range("AQ16").GoalSeek Goal:=0, ChangingCell:=Range("AC38")
Range("AQ17").GoalSeek Goal:=0, ChangingCell:=Range("AC39")
Range("AQ18").GoalSeek Goal:=0, ChangingCell:=Range("AC40")
Range("AQ19").GoalSeek Goal:=0, ChangingCell:=Range("AC41")
Range("AQ20").GoalSeek Goal:=0, ChangingCell:=Range("AC42")
Range("AQ21").GoalSeek Goal:=0, ChangingCell:=Range("AC43")
Range("AQ22").GoalSeek Goal:=0, ChangingCell:=Range("AC44")
Range("AQ23").GoalSeek Goal:=0, ChangingCell:=Range("AC45")
Range("AQ24").GoalSeek Goal:=0, ChangingCell:=Range("AC46")
Range("AQ25").GoalSeek Goal:=0, ChangingCell:=Range("AC47")
So the cells to be "goal-seeked" start with AM8 continuing down column AM until row 25, by changing Y30, staying in column Y until row 47. Then the macro moves to the next column and goal-seeks rows 8-25 in AN, then AO, then AP then AQ.
Any help to so I can learn how to reduce this to a loop instead of manually doing the whole thing would be greatly appreciated.
I just joined this forum and I am only at beginner level with VB for Excel. I am looking for help to learn how to set up a loop to do something that I have already created a macro to do am looking for a way to make the coding more efficient and condensed. The existing macro looks like this:
Range("AM8").GoalSeek Goal:=0, ChangingCell:=Range("Y30")
Range("AM9").GoalSeek Goal:=0, ChangingCell:=Range("Y31")
Range("AM10").GoalSeek Goal:=0, ChangingCell:=Range("Y32")
Range("AM11").GoalSeek Goal:=0, ChangingCell:=Range("Y33")
Range("AM12").GoalSeek Goal:=0, ChangingCell:=Range("Y34")
Range("AM13").GoalSeek Goal:=0, ChangingCell:=Range("Y35")
Range("AM14").GoalSeek Goal:=0, ChangingCell:=Range("Y36")
Range("AM15").GoalSeek Goal:=0, ChangingCell:=Range("Y37")
Range("AM16").GoalSeek Goal:=0, ChangingCell:=Range("Y38")
Range("AM17").GoalSeek Goal:=0, ChangingCell:=Range("Y39")
Range("AM18").GoalSeek Goal:=0, ChangingCell:=Range("Y40")
Range("AM19").GoalSeek Goal:=0, ChangingCell:=Range("Y41")
Range("AM20").GoalSeek Goal:=0, ChangingCell:=Range("Y42")
Range("AM21").GoalSeek Goal:=0, ChangingCell:=Range("Y43")
Range("AM22").GoalSeek Goal:=0, ChangingCell:=Range("Y44")
Range("AM23").GoalSeek Goal:=0, ChangingCell:=Range("Y45")
Range("AM24").GoalSeek Goal:=0, ChangingCell:=Range("Y46")
Range("AM25").GoalSeek Goal:=0, ChangingCell:=Range("Y47")
Range("AN8").GoalSeek Goal:=0, ChangingCell:=Range("Z30")
Range("AN9").GoalSeek Goal:=0, ChangingCell:=Range("Z31")
Range("AN10").GoalSeek Goal:=0, ChangingCell:=Range("Z32")
Range("AN11").GoalSeek Goal:=0, ChangingCell:=Range("Z33")
Range("AN12").GoalSeek Goal:=0, ChangingCell:=Range("Z34")
Range("AN13").GoalSeek Goal:=0, ChangingCell:=Range("Z35")
Range("AN14").GoalSeek Goal:=0, ChangingCell:=Range("Z36")
Range("AN15").GoalSeek Goal:=0, ChangingCell:=Range("Z37")
Range("AN16").GoalSeek Goal:=0, ChangingCell:=Range("Z38")
Range("AN17").GoalSeek Goal:=0, ChangingCell:=Range("Z39")
Range("AN18").GoalSeek Goal:=0, ChangingCell:=Range("Z40")
Range("AN19").GoalSeek Goal:=0, ChangingCell:=Range("Z41")
Range("AN20").GoalSeek Goal:=0, ChangingCell:=Range("Z42")
Range("AN21").GoalSeek Goal:=0, ChangingCell:=Range("Z43")
Range("AN22").GoalSeek Goal:=0, ChangingCell:=Range("Z44")
Range("AN23").GoalSeek Goal:=0, ChangingCell:=Range("Z45")
Range("AN24").GoalSeek Goal:=0, ChangingCell:=Range("Z46")
Range("AN25").GoalSeek Goal:=0, ChangingCell:=Range("Z47")
Range("AO8").GoalSeek Goal:=0, ChangingCell:=Range("AA30")
Range("AO9").GoalSeek Goal:=0, ChangingCell:=Range("AA31")
Range("AO10").GoalSeek Goal:=0, ChangingCell:=Range("AA32")
Range("AO11").GoalSeek Goal:=0, ChangingCell:=Range("AA33")
Range("AO12").GoalSeek Goal:=0, ChangingCell:=Range("AA34")
Range("AO13").GoalSeek Goal:=0, ChangingCell:=Range("AA35")
Range("AO14").GoalSeek Goal:=0, ChangingCell:=Range("AA36")
Range("AO15").GoalSeek Goal:=0, ChangingCell:=Range("AA37")
Range("AO16").GoalSeek Goal:=0, ChangingCell:=Range("AA38")
Range("AO17").GoalSeek Goal:=0, ChangingCell:=Range("AA39")
Range("AO18").GoalSeek Goal:=0, ChangingCell:=Range("AA40")
Range("AO19").GoalSeek Goal:=0, ChangingCell:=Range("AA41")
Range("AO20").GoalSeek Goal:=0, ChangingCell:=Range("AA42")
Range("AO21").GoalSeek Goal:=0, ChangingCell:=Range("AA43")
Range("AO22").GoalSeek Goal:=0, ChangingCell:=Range("AA44")
Range("AO23").GoalSeek Goal:=0, ChangingCell:=Range("AA45")
Range("AO24").GoalSeek Goal:=0, ChangingCell:=Range("AA46")
Range("AO25").GoalSeek Goal:=0, ChangingCell:=Range("AA47")
Range("AP8").GoalSeek Goal:=0, ChangingCell:=Range("AB30")
Range("AP9").GoalSeek Goal:=0, ChangingCell:=Range("AB31")
Range("AP10").GoalSeek Goal:=0, ChangingCell:=Range("AB32")
Range("AP11").GoalSeek Goal:=0, ChangingCell:=Range("AB33")
Range("AP12").GoalSeek Goal:=0, ChangingCell:=Range("AB34")
Range("AP13").GoalSeek Goal:=0, ChangingCell:=Range("AB35")
Range("AP14").GoalSeek Goal:=0, ChangingCell:=Range("AB36")
Range("AP15").GoalSeek Goal:=0, ChangingCell:=Range("AB37")
Range("AP16").GoalSeek Goal:=0, ChangingCell:=Range("AB38")
Range("AP17").GoalSeek Goal:=0, ChangingCell:=Range("AB39")
Range("AP18").GoalSeek Goal:=0, ChangingCell:=Range("AB40")
Range("AP19").GoalSeek Goal:=0, ChangingCell:=Range("AB41")
Range("AP20").GoalSeek Goal:=0, ChangingCell:=Range("AB42")
Range("AP21").GoalSeek Goal:=0, ChangingCell:=Range("AB43")
Range("AP22").GoalSeek Goal:=0, ChangingCell:=Range("AB44")
Range("AP23").GoalSeek Goal:=0, ChangingCell:=Range("AB45")
Range("AP24").GoalSeek Goal:=0, ChangingCell:=Range("AB46")
Range("AP25").GoalSeek Goal:=0, ChangingCell:=Range("AB47")
Range("AQ8").GoalSeek Goal:=0, ChangingCell:=Range("AC30")
Range("AQ9").GoalSeek Goal:=0, ChangingCell:=Range("AC31")
Range("AQ10").GoalSeek Goal:=0, ChangingCell:=Range("AC32")
Range("AQ11").GoalSeek Goal:=0, ChangingCell:=Range("AC33")
Range("AQ12").GoalSeek Goal:=0, ChangingCell:=Range("AC34")
Range("AQ13").GoalSeek Goal:=0, ChangingCell:=Range("AC35")
Range("AQ14").GoalSeek Goal:=0, ChangingCell:=Range("AC36")
Range("AQ15").GoalSeek Goal:=0, ChangingCell:=Range("AC37")
Range("AQ16").GoalSeek Goal:=0, ChangingCell:=Range("AC38")
Range("AQ17").GoalSeek Goal:=0, ChangingCell:=Range("AC39")
Range("AQ18").GoalSeek Goal:=0, ChangingCell:=Range("AC40")
Range("AQ19").GoalSeek Goal:=0, ChangingCell:=Range("AC41")
Range("AQ20").GoalSeek Goal:=0, ChangingCell:=Range("AC42")
Range("AQ21").GoalSeek Goal:=0, ChangingCell:=Range("AC43")
Range("AQ22").GoalSeek Goal:=0, ChangingCell:=Range("AC44")
Range("AQ23").GoalSeek Goal:=0, ChangingCell:=Range("AC45")
Range("AQ24").GoalSeek Goal:=0, ChangingCell:=Range("AC46")
Range("AQ25").GoalSeek Goal:=0, ChangingCell:=Range("AC47")
So the cells to be "goal-seeked" start with AM8 continuing down column AM until row 25, by changing Y30, staying in column Y until row 47. Then the macro moves to the next column and goal-seeks rows 8-25 in AN, then AO, then AP then AQ.
Any help to so I can learn how to reduce this to a loop instead of manually doing the whole thing would be greatly appreciated.