ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting .OnAction of a command button terminates my macro..... (https://www.excelbanter.com/excel-programming/337622-setting-onaction-command-button-terminates-my-macro.html)

[email protected]

Setting .OnAction of a command button terminates my macro.....
 
I am adding buttons to a spreadsheet programmatically and stepping
through the macro, it gets to the line

ActiveSheet.Buttons("Survey").OnAction = "SCI"

and the macro ends. The OnAction has been set but the macro will not
carry on after that. No error message, nothing.

I need to set the onactions of many buttons but cannot get past the
first one.

Anyone got any ideas?

Using Excel 2002.

Many thanks,
Ian


Norman Jones

Setting .OnAction of a command button terminates my macro.....
 
Hi Ian,

I see nothing contentious in the code snippet.

Post the following code which does not run.


---
Regards,
Norman



wrote in message
oups.com...
I am adding buttons to a spreadsheet programmatically and stepping
through the macro, it gets to the line

ActiveSheet.Buttons("Survey").OnAction = "SCI"

and the macro ends. The OnAction has been set but the macro will not
carry on after that. No error message, nothing.

I need to set the onactions of many buttons but cannot get past the
first one.

Anyone got any ideas?

Using Excel 2002.

Many thanks,
Ian




ruff

Setting .OnAction of a command button terminates my macro.....
 
Hi Norman,

Here is the full code:

Sub Splash_Screen()

Sheets.Add befo=Sheets(1)
Sheets(1).Name = "Navigation"
Cells.Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With

ActiveSheet.Buttons.Add(50, 50, 100, 50).Name = "Survey"
ActiveSheet.Buttons("Survey").Caption = "Survey"
ActiveSheet.Buttons("Survey").OnAction = "SCI"

ActiveSheet.Buttons.Add(200, 50, 100, 50).Name = "Prices"
ActiveSheet.Buttons("Survey").Caption = "Prices"
ActiveSheet.Buttons("Survey").OnAction = "Prices"

Range("A1").Select

End Sub


Norman Jones

Setting .OnAction of a command button terminates my macro.....
 
Hi Ruff,

Your code ran for me.

You should, however, change:

ActiveSheet.Buttons("Survey").Caption = "Prices"
ActiveSheet.Buttons("Survey").OnAction = "Prices"


to:

ActiveSheet.Buttons("Prices").Caption = "Prices"
ActiveSheet.Buttons("Prices").OnAction = "Prices"

Subject to this change, your macro achieved, for me, all that you asked of
it.


---
Regards,
Norman



"ruff" wrote in message
oups.com...
Hi Norman,

Here is the full code:

Sub Splash_Screen()

Sheets.Add befo=Sheets(1)
Sheets(1).Name = "Navigation"
Cells.Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With

ActiveSheet.Buttons.Add(50, 50, 100, 50).Name = "Survey"
ActiveSheet.Buttons("Survey").Caption = "Survey"
ActiveSheet.Buttons("Survey").OnAction = "SCI"

ActiveSheet.Buttons.Add(200, 50, 100, 50).Name = "Prices"
ActiveSheet.Buttons("Survey").Caption = "Prices"
ActiveSheet.Buttons("Survey").OnAction = "Prices"

Range("A1").Select

End Sub




ruff

Setting .OnAction of a command button terminates my macro.....
 
Thanks Norman. I restarted Excel and it appears to work now. Very
strange!



All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com