button names changed on copied sheet

  • Thread starter Thread starter oldyork90
  • Start date Start date
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
 
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
 
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.
 
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.
 
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
 
Back
Top