View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Cell Value on Toolbar

One way

Option Explicit

Const WS_RANGE As String = "B10"

Private Sub Worksheet_Activate()
Dim oCtl As CommandBarControl

On Error Resume Next
Set oCtl = Application.CommandBars.FindControl(Tag:="cellValu e")
oCtl.Delete
On Error GoTo 0
With Application.CommandBars("Standard"). _
Controls.Add(Type:=msoControlButton)
.Tag = "cellValue"
.Style = msoButtonCaption
.Caption = Me.Range(WS_RANGE).Value
End With
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Dim oCtl As CommandBarControl

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Set oCtl = CommandBars.FindControl(Tag:="cellValue")
oCtl.Caption = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"HilcrRWise" wrote
in message ...

Is it possible to show the value of a cell on a custom toolbar. Cell
location will not change, but cell content will.


--
HilcrRWise
------------------------------------------------------------------------
HilcrRWise's Profile:

http://www.excelforum.com/member.php...o&userid=11699
View this thread: http://www.excelforum.com/showthread...hreadid=494807