Excel vba shape row number is different in excel 2016 and 2013

Hi,

Excel 2016 provides correct row number of shape plus sign where as same code is not providing correct row number in excel 2013.
Below is the code used in macro.

Set b = ActiveSheet.Shapes(Application.Caller)
    With b.TopLeftCell
        lngMyRowNumber = .Row
    End With

Please suggest.

Thank you.
Vishal BharakhadaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fabrice LambertFabrice LambertCommented:
Hi,

1st thing, are you sure that ActiveSheet is the correct worksheet ?

I do not advice using such object, as its value depend on user's action, and is by nature chaotic.
As a programmer, you don't want to use chaotic objects.

Prefer referencing explicitly and precisely the object you want to use.
Dim ws as Excel.Worksheet
Set ws = ActiveWorksheet    '// Wrong !! we don't know wich worksheet it is

Set ws = ThisWorkbook.Worksheets(1)    '// Ok, ws is the 1st worksheet

Open in new window

Same goes for ActiveWorkbook, ActiveShape, Selection ect .... never ever use these.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vishal BharakhadaAuthor Commented:
Hi Fabrice,

Thank you for your comment.

As per your suggestion have tried below code and still there is no luck.

 Dim wb As Workbook
 Dim ws As Worksheet
 Set wb = ThisWorkbook
 Set ws = ThisWorkbook.Worksheets("Additional_Details")
 
    Set b = ws.Shapes(Application.Caller)
    With b.TopLeftCell
        cs = .Row
    End With

Regards,
Vishal G. B.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.