Assigning ID's to Shapes in VBA

gemcgraw

Board Regular
Joined
Mar 11, 2011
Messages
72
Hello -
I'm working on a new project where a client is wanting a spreadsheet to track where products are staged in their warehouse. They keep pallets staged as "inventory markers" for a different products. Their concept is to enter a pallet number ("Pallet 001") in their Excel database (Sheet1) and then it updates the pallet (Sheet2) with a product number.


My suggestion would be to have "shapes" on Sheet2, representing a pallet. When they enter the pallet number (shape) ID on Sheet1, it would append the text in the shape (sheet2) and include the product number on Sheet2. (e.g. Shape1 has a default text of "Pallet 001". When a product is assigned to Shape1 "Pallet 001" on sheet1, the text is appended, "Pallet 001 - Product XYZ" on Sheet2.


My problem is trying to figure out how to tie an "ID" to shapes. I know how to have VBA create a given number of shapes, but how do I assign them unique IDs (like a listbox) so that they can be referenced again, to update the text of any given shape?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Maybe you can adapt something like this.
Code:
Sub AddShapesWithNames()
Dim i As Long
Application.ScreenUpdating = False
For i = 1 To 10
    ActiveSheet.Shapes.AddShape(msoShapeRectangle, 5 * i, 10 * i, 25, 25).Select 'change size & positions to suit
    Selection.Name = "Pallet " & Choose(Len(CStr(i)), "00", "0", "") & i
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,610
Members
449,174
Latest member
ExcelfromGermany

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