VBA macro for goalseek entire column

stronk

New Member
Joined
Dec 12, 2013
Messages
3
I'm trying to use a macro to produce a value in a column of cells, based on 2 other cells in the same row. I'm obviously missing something as I keep getting a 1004 error "reference not valid."

Code:
Code:
Sub Macro1()

Dim i As Integer
For i = 2 To 23
Cells(i, 18).GoalSeek Goal:=Cells(i, 2).Value, ChangingCell:=Cells(i, 16)
Next i
 

End Sub
Can any one point out what the issue causing this mihgt be?
Many thanks.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
No merged cells. What version are you using? I'm on 2007 if that would be a contributing factor....
 
Upvote 0
all cells in column 18 contain a formula. Using the goal seek from the toolbar works just fine.
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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