Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 38
Default Macro Does not Work on Button

I have recorded a GoalSeek macro in Excel 97 SR2, which works when
called from the Tools | Macro menu, but when I call it from a button
on the spreadsheet then the macro fails in the GoalSeek command.

My macro is . . .

Sub BalancePC()
'
' BalancePC Macro
' Macro recorded 24/03/2009 by Alan G Lloyd
'

'
Worksheets("Financial Statement").Range("M37").GoalSeek _
Goal:=0, _
ChangingCell:=Worksheets("Financial Statement").Range("I25")

End Sub

Alan Lloyd
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Macro Does not Work on Button

It is difficult to comment without reviewing. Could you please right click
the button 'Assign Macro' and reassign the macro.

If this post helps click Yes
---------------
Jacob Skaria


" wrote:

I have recorded a GoalSeek macro in Excel 97 SR2, which works when
called from the Tools | Macro menu, but when I call it from a button
on the spreadsheet then the macro fails in the GoalSeek command.

My macro is . . .

Sub BalancePC()
'
' BalancePC Macro
' Macro recorded 24/03/2009 by Alan G Lloyd
'

'
Worksheets("Financial Statement").Range("M37").GoalSeek _
Goal:=0, _
ChangingCell:=Worksheets("Financial Statement").Range("I25")

End Sub

Alan Lloyd

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Macro Does not Work on Button

Maybe this will help:
http://www.anthony-vba.kefra.com/vba/vbabasic1.htm

Also, you may need this:
http://peltiertech.com/Excel/SolverVBA.html#Solver3


Good luck,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jacob Skaria" wrote:

It is difficult to comment without reviewing. Could you please right click
the button 'Assign Macro' and reassign the macro.

If this post helps click Yes
---------------
Jacob Skaria


" wrote:

I have recorded a GoalSeek macro in Excel 97 SR2, which works when
called from the Tools | Macro menu, but when I call it from a button
on the spreadsheet then the macro fails in the GoalSeek command.

My macro is . . .

Sub BalancePC()
'
' BalancePC Macro
' Macro recorded 24/03/2009 by Alan G Lloyd
'

'
Worksheets("Financial Statement").Range("M37").GoalSeek _
Goal:=0, _
ChangingCell:=Worksheets("Financial Statement").Range("I25")

End Sub

Alan Lloyd

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 38
Default Macro Does not Work on Button

On Mar 28, 5:20�am, ryguy7272
wrote:
"Jacob Skaria" wrote:
It is difficult to comment without reviewing. Could you please right click
the button 'Assign Macro' and reassign the macro.


If this post helps click Yes
---------------
Jacob Skaria



RyGuy7272

I've looked at your referenced links but they re-interate whate I've
done in generating my macro.

Jacob

Couldn't see your post directly (don't know why) but only as
referenced by RyGuy7272

Couldn't find 'Assign Macro' anywhere in my Excel or VBA, but right-
clicked on button in Design Mode & selected View Code, deleted the
event code, saved & re-opened and re-entered the macro in the View
Code button event. No change

Macro runs if run in Excel | Tools | Macro or in VBA | Tools |
Macros.

When run from button click it fails with Error 1004, which does not
appear in the list of trappable errors. If Debug selected on fail then
yellow margin arrow is against bottom line of GoalSeek code - does
this mean the error is in that line, or only in the complete code
line.

I've tried more fully qualifying the ranges with Sheet1 instead of
Worksheet("Financial Statement"), but no difference.

Cell function trail is ...

I25 - constant
I27 = Sum(I4:I26)
C28 = C27 - I27
M36 = C28 + C36
C36 = SUM(C32:C35)
C32 - constant
M27 = I32 - M36
I32 - constant

I just cannot understand why the macro function code works fine as a
macro call, but the same code fails when called from a button event
calling that macro function.

Alan Lloyd
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Macro Does not Work on Button

Yeah, sometimes I have trouble seeing posts from other posters too. Do you
use Mozilla/Firefox? Sometimes new posts don't display in that browser (no
idea why). Try MS Explorer. As I said before.....

Maybe this will help:
http://www.anthony-vba.kefra.com/vba/vbabasic1.htm

Also, you may need this:
http://peltiertech.com/Excel/SolverVBA.html#Solver3


Good luck,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


" wrote:

On Mar 28, 5:20�am, ryguy7272
wrote:
"Jacob Skaria" wrote:
It is difficult to comment without reviewing. Could you please right click
the button 'Assign Macro' and reassign the macro.


If this post helps click Yes
---------------
Jacob Skaria



RyGuy7272

I've looked at your referenced links but they re-interate whate I've
done in generating my macro.

Jacob

Couldn't see your post directly (don't know why) but only as
referenced by RyGuy7272

Couldn't find 'Assign Macro' anywhere in my Excel or VBA, but right-
clicked on button in Design Mode & selected View Code, deleted the
event code, saved & re-opened and re-entered the macro in the View
Code button event. No change

Macro runs if run in Excel | Tools | Macro or in VBA | Tools |
Macros.

When run from button click it fails with Error 1004, which does not
appear in the list of trappable errors. If Debug selected on fail then
yellow margin arrow is against bottom line of GoalSeek code - does
this mean the error is in that line, or only in the complete code
line.

I've tried more fully qualifying the ranges with Sheet1 instead of
Worksheet("Financial Statement"), but no difference.

Cell function trail is ...

I25 - constant
I27 = Sum(I4:I26)
C28 = C27 - I27
M36 = C28 + C36
C36 = SUM(C32:C35)
C32 - constant
M27 = I32 - M36
I32 - constant

I just cannot understand why the macro function code works fine as a
macro call, but the same code fails when called from a button event
calling that macro function.

Alan Lloyd

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Button in a work sheet Finance Guru Excel Discussion (Misc queries) 9 November 15th 07 09:17 PM
U.S. Command Button Macro won't work in Australian version 2003 Ron in Dallas Excel Discussion (Misc queries) 1 December 23rd 05 05:08 PM
Button suddenly does not work Man Utd New Users to Excel 2 October 20th 05 06:41 AM
Spin button in a work sheet - how do I make it work? [email protected] Excel Worksheet Functions 1 April 7th 05 08:43 PM
Assign Macro to button in Excel doesnt work Any ideas? Mike@Becketts Excel Discussion (Misc queries) 2 December 20th 04 02:47 PM


All times are GMT +1. The time now is 03:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"