button names changed on copied sheet

O

oldyork90

These damn buttons....

I have a collection of form buttons on sheet. They are all assigned to the same sub(). In that sub() I obtain their name:

Dim button_name As String: button_name = Application.Caller

When I do a copy sheet (leftclick tab, move or copy, x create copy) everything is just fine EXCEPT the buttons have changed their names.

Select Case button_name
Case "Button 2"
row_day = oMyWs.Range("row_day_1").row
Case "Button 3"
row_day = oMyWs.Range("row_day_2").row

The above fails because "Button 2" is now "Button 1". There is no "Button 1" on the source page (probably having been deleted during development)

What gives? Can I fix this or am I doomed.

Thank you.
Excel 2010
 
G

GS

See my reply to your other post! My suggestion fixes all unexpected
behaviors associated with using controls on worksheets...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
W

witek

These damn buttons....

I have a collection of form buttons on sheet. They are all assigned to the same sub(). In that sub() I obtain their name:

Dim button_name As String: button_name = Application.Caller

When I do a copy sheet (leftclick tab, move or copy, x create copy) everything is just fine EXCEPT the buttons have changed their names.

Select Case button_name
Case "Button 2"
row_day = oMyWs.Range("row_day_1").row
Case "Button 3"
row_day = oMyWs.Range("row_day_2").row

The above fails because "Button 2" is now "Button 1". There is no "Button 1" on the source page (probably having been deleted during development)

What gives? Can I fix this or am I doomed.

Thank you.
Excel 2010

I do not experience that now but I remember such situation from the past
Change names from "button x" to more custom names.
 
O

oldyork90

Garry...
See my reply to your other post! My suggestion fixes all unexpected
behaviors associated with using controls on worksheets...

The source sheet contained buttons "Button 2"....3,4,5,6

This worked

Set shp2 = ws.Shapes.Item("Button 2")
shp2.Name = "Button 1"

But this failed

Set shp2 = ws.Shapes.Item("Button 3")
shp2.Name = "Button 2"

I reloaded the object... still failed. That name persists somewhere but I couldn't find it. I dumped the names and "Button 2" was not in use. I finally mangled them but good, as in

"ButtonDay1", "ButtonDay2" ..... 14

and everything renamed just fine.

Thanks.
 
G

GS

Garry...
See my reply to your other post! My suggestion fixes all unexpected
behaviors associated with using controls on worksheets...

The source sheet contained buttons "Button 2"....3,4,5,6

This worked

Set shp2 = ws.Shapes.Item("Button 2")
shp2.Name = "Button 1"

But this failed

Set shp2 = ws.Shapes.Item("Button 3")
shp2.Name = "Button 2"

I reloaded the object... still failed. That name persists somewhere
but I couldn't find it. I dumped the names and "Button 2" was not in
use. I finally mangled them but good, as in

"ButtonDay1", "ButtonDay2" ..... 14

and everything renamed just fine.

Thanks.

FOR NOW!!! See what happens next time you hide/unhide the area...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top