Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Programming Ideas

Brian,

You could put code into a worksheet calculate event macro that would change
the caption on a toolbar button. This one would go into the ThisWorkbook
module and would work for all sheets.

For arguments sake - say the value you want is in cell Sheet1!A1
You will need to know the name of the toolbar and the position of the
button. So we will make a new toolbar with only one button.

See if these work for you.
Caution: watch for word wrap. Also if you copy and paste this code,
compile it with the Debugger because extraneous spaces sometimes show up.

================================================
' Macro to create the toolbar and the button when the workbook opens

Private Sub Workbook_Open()
Dim cbrCommandBar As CommandBar
Dim cbcCommandBarButton As CommandBarButton
Dim cst as Double

' Remove flickering and improve speed
Application.DisplayAlerts = False
Application.ScreenUpdating = False

' remove toolbar before recreating it.
'(this line can be deleted later if you want to have
'the button there all the time.
On Error Resume Next
Application.CommandBars(" Cost ").Delete
On Error GoTo 0

' add the bar
Set cbrCommandBar = _
Application.CommandBars.Add
cbrCommandBar.Name = " Cost "

cst = Sheets("Sheet1").Range("A1")
' Add command button control to the control's
' collection of CommandBar objects.
With cbrCommandBar.Controls
Set cbcCommandBarButton = _
.Add(msoControlButton)
With cbcCommandBarButton
.Style = msoButtonIconAndCaption
.Caption = " Cost: " & cst
End With
End With

cbrCommandBar.Visible = True
cbrCommandBar.Position = msoBarTop

Set cbrCommandBar = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

''' Macro to change button caption after each update
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Dim cst as Double
Application.DisplayAlerts = False
Application.ScreenUpdating = False

cst = Sheets("Sheet1").Range("A1")
Application.CommandBars(" Cost ").Controls(1).Caption = _
" Cost: " & cst

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

''' Macro to delete the button when the workbook
' is closed.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars(" Cost ").Delete
End Sub

--
sb
"brian" wrote in message
...
1. I was actually hoping the value of a cell could be
displayed on a button in a toolbar, above the worksheet,
where it will always be there. It would say "Cost:
{value}" and would be updated during each calculation.
When I make a change to my estimate, I need to watch the
total cost value to see how it is affected by my change.
I was hopeful that Excel's "watch box" would work for me,
but it is not quite right because it show the cell address
instead of something easier to remember).

2. Word Art works ok for individual watermarks, but it
would be nice if the watermark text could be updated when
the sheet name changes (or using some type of control).
It would be tedious to set up WordArt watermarks every
time I set up an estimate sheet because you have to put 3
or 4 of them on each page so that you see it where-ever
you are in the estimate.

TIA

Brian


-----Original Message-----
1. Can you elaborate more? From what I understand, you

want a button
on a toolbar that you click and it displays the value of

a cell in a
drop-down, with a short description. Where does the

description come
from? Also, which cell's value would it display?

2. One way to do what you are saying is just put the

estimate you want
in Page Break Preview mode (In the View button). That

would make it
stick out and have a kind of watermark. There are other

options,
although this would be the simplest.

Let me know if you have more questions.

Mark

---
Mark Bigelow
mjbigelow at hotmail dot com
http://hm.imperialoiltx.com

*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.



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
any ideas if this can be done CarlM[_2_] Excel Worksheet Functions 2 October 27th 09 03:52 PM
Rounding in VBA - Any ideas? Michiel via OfficeKB.com Excel Worksheet Functions 5 September 9th 08 02:57 AM
Anyone else have any ideas?? M&M[_2_] Excel Discussion (Misc queries) 3 August 11th 07 01:51 PM
Any Ideas? GAIL HORVATH Excel Worksheet Functions 2 May 30th 05 04:17 PM
Any Ideas Greg B Excel Discussion (Misc queries) 7 May 16th 05 03:41 AM


All times are GMT +1. The time now is 09:46 AM.

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

About Us

"It's about Microsoft Excel"