ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Object Numbering (https://www.excelbanter.com/excel-programming/312818-object-numbering.html)

Bryan

Object Numbering
 
Is there a way to change the object numbering - always start from the same
number?

Reason - I draw a group box with 5 buttons inside for each user (0-12)

If I have 0 users, then I delete all the objects.

Right now, I have a kludge in that I write to a hidden cell the last object
number and the number of objects. But I only check for the last 4 digits of
the object number (and after playing around several times I'm approaching 5
digits), and I really don't want to go into string manipulation to get a
valid number.

I'd like to always start user 1 with drawing object #100

Thanks,

Bryan

Dick Kusleika[_3_]

Object Numbering
 
Bryan

You can name the object whatever you like (almost). So why not just name
them as you create them starting with 100. Even better, don't create and
delete the objects. Make them Visible/Invisible based on your needs.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Bryan" wrote in message
...
Is there a way to change the object numbering - always start from the same
number?

Reason - I draw a group box with 5 buttons inside for each user (0-12)

If I have 0 users, then I delete all the objects.

Right now, I have a kludge in that I write to a hidden cell the last

object
number and the number of objects. But I only check for the last 4 digits

of
the object number (and after playing around several times I'm approaching

5
digits), and I really don't want to go into string manipulation to get a
valid number.

I'd like to always start user 1 with drawing object #100

Thanks,

Bryan




Bryan

Object Numbering
 
Can you give me an example of how to name an object, and an example of how to
hide that object.

Hide/unhide sounds like the ticket to Disney World for me!

Thanks

Bryan

"Dick Kusleika" wrote:

Bryan

You can name the object whatever you like (almost). So why not just name
them as you create them starting with 100. Even better, don't create and
delete the objects. Make them Visible/Invisible based on your needs.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Bryan" wrote in message
...
Is there a way to change the object numbering - always start from the same
number?

Reason - I draw a group box with 5 buttons inside for each user (0-12)

If I have 0 users, then I delete all the objects.

Right now, I have a kludge in that I write to a hidden cell the last

object
number and the number of objects. But I only check for the last 4 digits

of
the object number (and after playing around several times I'm approaching

5
digits), and I really don't want to go into string manipulation to get a
valid number.

I'd like to always start user 1 with drawing object #100

Thanks,

Bryan





Dick Kusleika[_3_]

Object Numbering
 
Bryan

Can you give me an example of how to name an object, and an example of how

to
hide that object.


I assume you're using commandbuttons from the Forms toolbar. You can rename
those buttons using the Name Box (just to the left of the formula bar). If
it says Button 200, you can select the Name Box and type in Button100, or
whatever you want.

The Visible property of the Shape object is how I would show/hide the
buttons. You can loop through all the shapes and hide/show based on their
name. For instance, if you have 12 rows of 5 buttons, you could name them
like BtnR1C1 to BtnR12C5, then test that the name as the right R value to
show or hide.

Another way is to use the TopLeftCell property to determine which row it's
in. That way, it wouldn't matter what the name of the button was. Assume
you have 4 rows of 4 buttons each. The first row's TopLeftCell is in row 9,
the second in Row 12, etc. You could use a sub like this to determine how
many rows to show

Sub HideButtons()

Dim Shp As Shape
Dim sGroup As Shape
Dim lUsers As Long

Const lSHPOFFSET As Long = 6

Set sGroup = Sheet1.Shapes("Group Box 1")
lUsers = Sheet1.Range("a1").Value 'I don't know where you get this

For Each Shp In Sheet1.Shapes
'Exclude shapes that are not in the group box
If Not Intersect(Shp.TopLeftCell, _
Sheet1.Range(sGroup.TopLeftCell, sGroup.BottomRightCell)) _
Is Nothing Then

'Hide/Show buttons based on which row they're in
If Shp.TopLeftCell.Row lSHPOFFSET + (lUsers * 3) Then
Shp.Visible = False
Else
Shp.Visible = True
End If
End If
Next Shp

End Sub

That should get you started. If you want more specific help based on your
particular situation, provide some details and I will be happy to help.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com




All times are GMT +1. The time now is 11:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com