Hello neasthead98,
The key to this macro being used by all the "pictures" is identifying which picture was clicked. Excel has a property named Caller that determines how VBA was called from Excel. This property may either be the name of an object or the object itself depending on how Excel invoked the VBA code.
In this case, the name of the picture, which is actually an AutoShape object, is returned by Application.Caller when the shape is clicked. An object variable is then assigned to the clicked shape.
This object variable Shp now allows VBA to access the properties and methods of the clicked shape. Objects are referenced in VBA by 2 points: the Upper Left Cell and the Lower Right Cell that the object occupies. Since placement is seldom done precisely, the code takes the average of the current placement to determine the which row the shape is on. the variable R is the row and Cells(R, .TopLeftCell.Column) is the address of the cell next to the "picture". One is then added to contents of this cell.
Bookmarks