Microsoft Visual Basic Error 400

khwaja

New Member
Joined
Aug 19, 2005
Messages
14
I am using the following code to automate goal seek with an assigned button. Each time I tried to run it I get an error with big red X with 400. Any idea how to fix this?

Sub GoalSeek1_Click()
Range("E22").GoalSeek Goal:=Range("6000").Value, ChangingCell:=Range("D6")
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
59,029
Office Version
  1. 365
Platform
  1. Windows
This is an invalid range reference. You are missing the column part of the cell address.
Range("6000")
 

khwaja

New Member
Joined
Aug 19, 2005
Messages
14
Thanks a lot for your time. I have now updated the formula as under to get the value from a cell. I have amended it a bit.

Sub GoalSeek1_Click()
Range("E22").GoalSeek Goal:=Range("B22").Value, ChangingCell:=Range("D6")
End Sub

But I run it I get runtime error 1004 Reference isn't valid.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
59,029
Office Version
  1. 365
Platform
  1. Windows
Sorry, I hae been away for a few days.

Can you provide me with what is in cells E22, B22, and D6?
 

khwaja

New Member
Joined
Aug 19, 2005
Messages
14
Not a problem at all. Appreciate you coming back. I think you are very clever because you knew what silly users like are usually up to. As you probably expected, I had the wrong cell refs. It is now working well. Very grateful and apologies for wasting your time.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
59,029
Office Version
  1. 365
Platform
  1. Windows
You are welcome. Glad you got it all figured it out.
:)
 

Forum statistics

Threads
1,141,474
Messages
5,706,597
Members
421,459
Latest member
drewber

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
Top