1

There are many questions like mine and I just tried out the solution mentioned in many places, for example here. But for me it just returns the error "Run-time error '1004': Unable to get the Buttons property of the worksheet class" when I enter the following code:

Sub Mainscoresheet() 
     ' Mainlineup Macro
    Dim b As Object, RowNumber As Integer 
    Set b = ActiveSheet.Buttons(Application.Caller) 'here I get the error
    With b.TopLeftCell 
        RowNumber = .Row
    End With 
    MsgBox "Row Number " & RowNumber 
End Sub

Does anyone know another solution which would fix my problem? If you need any further information, please feel free to ask. Thanks in advance!

Kind regards, Julia

Community
  • 1
  • 1
Julia
  • 1
  • 6
  • It works for me. Are you calling it from a FORMS button (not an ActiveX) button? – Doug Glancy Apr 23 '16 at 18:30
  • As pointed out by @MarcoVos you are probably using ActiveX controls and therefore get this error. Yet, again, if you are using ActiveX controls then each button has its own sub and you don't need to wonder which button has been pressed. Only form controls can "share" subs. – Ralph Apr 23 '16 at 19:02

1 Answers1

2

I tested your code. It works fine with a formsbutton, but not with an ActiveXbutton. Could that be the problem?

Marco Vos
  • 2,888
  • 1
  • 9
  • 10
  • thank you, it solved my problem - sorry I reply only now, I postponed this task until now – Julia Jan 23 '17 at 06:23