Setting .OnAction of a command button terminates my macro.....

  • Thread starter Thread starter thfc1882
  • Start date Start date
T

thfc1882

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
 
Hi Ian,

I see nothing contentious in the code snippet.

Post the following code which does not run.
 
Hi Norman,

Here is the full code:

Sub Splash_Screen()

Sheets.Add before:=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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top