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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Michele

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

Forum statistics

Threads
1,215,067
Messages
6,122,949
Members
449,095
Latest member
nmaske

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