Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! . |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
any ideas if this can be done | Excel Worksheet Functions | |||
Rounding in VBA - Any ideas? | Excel Worksheet Functions | |||
Anyone else have any ideas?? | Excel Discussion (Misc queries) | |||
Any Ideas? | Excel Worksheet Functions | |||
Any Ideas | Excel Discussion (Misc queries) |