Run-time error '1004' when calling Application.Caller

ingcerullo

New Member
Joined
Aug 25, 2016
Messages
1
Dear all,
this is my first post here and I have been using vba only for a month, so sorry for any naïve question.
In my excel sheet I have a button which is connected to a macro which copies data from another workbook to the row of the button. The code is here below. I need to get the row number of the button but for some reason I always get an error.

Public Sub CommandButton21_Click()
Dim prova As Range
Dim i, FeatNo, RowButt, RowFeatSource, SourceFirstFeatRow As Integer

With ThisWorkbook.ActiveSheet
Set prova = .Buttons(Application.Caller).TopLeftCell
RowButt = prova.Row
MsgBox "RowButt " & RowButt
'End With

......
.....
End

I tried each of these three alternatives:

Code:
Set prova = .Buttons(Applacation.Caller).TopLeftCell 
Set prova = .Buttons("CommandButton21").TopLeftCell
Set prova = .Buttons(1).TopLeftCell

but it always returns the error "Run-time error '1004' Application-defined or object-defined error"
Can anyone please help me?
I am working with Excel 2010 on Windows 7 64 bit.

Thanks a lot,
Michele
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Michele

How did you create the button(s)?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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
Back
Top