Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Lon Sarnoff
 
Posts: n/a
Default How to determine button reference

My application copies a spreadsheet to create a second spreadsheet in the
same workbook, and massages the data in the second sheet. There are four
buttons in the first sheet, and I wish to hide three of them in the second
sheet. The button numbers of the first sheet change when they appear in the
second sheet. How can I identify the buttons in the second sheet so as to
hide them using the following statement: ActiveSheet.Shapes("Button
X").visible = False

--
Lon Sarnoff
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Are you using xl97?

IIRC, this "feature" was fixed in xl2k--but I could be remembering incorrectly.

Could you use the location of the button?

Option Explicit
Sub testme()
Dim fWks As Worksheet
Dim tWks As Worksheet
Dim AddrToClean As Variant
Dim iCtr As Long
Dim myRng As Range
Dim myShp As Shape
Dim HiddenCtr As Long

AddrToClean = Array("c6", "c10", "g13")

Set fWks = Worksheets("sheet1")
fWks.Copy after:=fWks

Set tWks = ActiveSheet

With tWks
HiddenCtr = 0
For Each myShp In .Shapes
For iCtr = LBound(AddrToClean) To UBound(AddrToClean)
If Intersect(.Range(myShp.TopLeftCell, _
myShp.BottomRightCell), _
.Range(AddrToClean(iCtr))) Is Nothing Then
'do nothing
Else
myShp.Visible = False
HiddenCtr = HiddenCtr + 1
Exit For
End If
Next iCtr
Next myShp
End With

'just a warning while testing.
If (UBound(AddrToClean) - LBound(AddrToClean) + 1) = HiddenCtr Then
'everything worked ok
'do nothing
Else
MsgBox "Only: " & HiddenCtr & " shapes were hidden!"
End If

End Sub

Lon Sarnoff wrote:

My application copies a spreadsheet to create a second spreadsheet in the
same workbook, and massages the data in the second sheet. There are four
buttons in the first sheet, and I wish to hide three of them in the second
sheet. The button numbers of the first sheet change when they appear in the
second sheet. How can I identify the buttons in the second sheet so as to
hide them using the following statement: ActiveSheet.Shapes("Button
X").visible = False

--
Lon Sarnoff


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maintaining cell reference after sorting GRITS Excel Discussion (Misc queries) 2 April 30th 23 07:42 PM
Command Button anomalies RWN Excel Discussion (Misc queries) 5 May 4th 05 05:09 AM
RELATIVE REFERENCE BUTTON Neil Mark Excel Discussion (Misc queries) 2 February 22nd 05 07:27 AM
Command Button VBA code Dave Peterson Excel Discussion (Misc queries) 2 January 25th 05 11:28 PM
Macro to simply bring up the Find dialogue box?? marika1981 Excel Discussion (Misc queries) 14 January 14th 05 10:47 PM


All times are GMT +1. The time now is 03:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"