Goal Seek Loop through every other column

dviper

New Member
Joined
Sep 20, 2003
Messages
30
I've to figure out a goal seek loop, but was stymied and out of time. So I did the long way (below) and it is very slow. Is there anyway to make this into a more elegant loop?

Sub Set_Price()
'
' Set_Price Macro
'

'
Range("I32").GoalSeek Goal:=Range("I25"), ChangingCell:=Range("I26")
Range("K32").GoalSeek Goal:=Range("K25"), ChangingCell:=Range("K26")
Range("M32").GoalSeek Goal:=Range("M25"), ChangingCell:=Range("M26")
Range("O32").GoalSeek Goal:=Range("O25"), ChangingCell:=Range("O26")
Range("Q32").GoalSeek Goal:=Range("Q25"), ChangingCell:=Range("Q26")
Range("S32").GoalSeek Goal:=Range("S25"), ChangingCell:=Range("S26")
Range("U32").GoalSeek Goal:=Range("U25"), ChangingCell:=Range("U26")
Range("W32").GoalSeek Goal:=Range("W25"), ChangingCell:=Range("W26")
Range("Y32").GoalSeek Goal:=Range("Y25"), ChangingCell:=Range("Y26")
Range("AA32").GoalSeek Goal:=Range("AA25"), ChangingCell:=Range("AA26")
Range("AC32").GoalSeek Goal:=Range("AC25"), ChangingCell:=Range("AC26")
Range("AE32").GoalSeek Goal:=Range("AE25"), ChangingCell:=Range("AE26")
Range("AG32").GoalSeek Goal:=Range("AG25"), ChangingCell:=Range("AG26")
Range("AI32").GoalSeek Goal:=Range("AI25"), ChangingCell:=Range("AI26")
Range("AK32").GoalSeek Goal:=Range("AK25"), ChangingCell:=Range("AK26")
Range("AM32").GoalSeek Goal:=Range("AM25"), ChangingCell:=Range("AM26")
Range("K56").Select
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Code:
Sub Set_Price()
  Dim iCol As Long
  
  For iCol = Columns("I").Column To Columns("AK").Column Step 2
    With Columns(iCol)
      .Cells(32).GoalSeek Goal:=.Cells(25).Value2, ChangingCell:=.Cells(26)
    End With
  Next iCol
End Sub
It won't go any faster.
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,114
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top