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:
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
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