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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,962
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
58,962
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
58,962
Office Version
  1. 365
Platform
  1. Windows
You are welcome. Glad you got it all figured it out.
:)
 

Forum statistics

Threads
1,141,203
Messages
5,704,926
Members
421,372
Latest member
Jamie11

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