ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   button names changed on copied sheet (https://www.excelbanter.com/excel-programming/449705-button-names-changed-copied-sheet.html)

[email protected]

button names changed on copied sheet
 
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



GS[_2_]

button names changed on copied sheet
 
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



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com


witek

button names changed on copied sheet
 
wrote:
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.


[email protected]

button names changed on copied sheet
 

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.

GS[_2_]

button names changed on copied sheet
 
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



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com



All times are GMT +1. The time now is 06:15 AM.

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