I'm building a workbook and I created a "Menu" sheet that I want to serve as a thin navigation bar to launch all of the various macros/userforms that run in the workbook.
My plan is to have one window always set to the "Menu" sheet and just be a thin bar on the left side of the work area. The other window would take up the rest of the workarea and display all of the other various sheets.
How do I get the first window to always display the menu sheet and execute the macros launched from that window in the other window? Also, let me know if you have any better ideas to do what I'm trying to do.
I'm currently doing something similar. I took a different approach that you could adopt.
So I have a workbook with many sheets, and a main 'Control Panel' worksheet where the user inputs their data and run macro buttons to do lots of magical things(!)
I just placed all my macro buttons in Row 1 of the sheet and then used the "Freeze" Panes tool to freeze the top row. That way, if the user is on the Control Panel Sheet, the macro tools are always available regardless of where they are on the sheet.
I have set up the same buttons (which are contextually appropriate) on the other worksheets. So essentially the user can operate them from anywhere.
Just some food for thought :)
Related
I'm new to VBA in excel, and I'm trying to put together a dashboard for my leadership to view...most of my background is in database query languages and not programming in this sense. I'm trying to build three buttons in excel: Overview, Direct, Indirect are the names to be exact. When I click Overview, I want my "Dashboard" to show all of the metrics I used in my overview calculations (charts, numbers, etc). If I click it again, I want it to hide them. The same with the other two buttons, If I click "overview" and my dashboard view is all of my overview metrics and graphs, and I click "Direct" I want all of my metrics, graphs to show my "Direct" metrics. The same goes for Indirect. So far I have one macro, it hides all objects (shapes, charts) in my active worksheet, but not the metrics (numbers) in the cells. It also hides the button that I assigned the macro too, so I can't unhide everything unless I open the VBA editor! I want each of my 3 "main" buttons to not hide when I click any of them, just my charts and metrics, and upon a second click of the button unhide.
Here's my sample code so far:
Sub HideEachShape()
Dim sObject As Shape
For Each sObject In ActiveSheet.Shapes
sObject.Visible = False
Next
End Sub
Pretty basic I know, but I'm new to this.
A client is asking me what I think should be done with .NET Windows Forms or similar, but maybe it's possible to do in Excel:
I already added some buttons and actions in a data sheet, but instead of showing all cells as shown by default by Excel, he wants the sheet to be inside an scrollable area. Something like this:
Is this possible? In case it's not clear enough, the scrollbars are just around the data rows and columns, not about the buttons and form items around the actual data
EIDT: I'll try to be more clear, I need all my Excel sheet and workspace to look like a Windows forms application, and the actual data (all the Excel cells) to be inside an scrollable area. I think it's not easy to understand because it's quite weird, as I sayed is my client who wants this.
BTW it wasn't a trial version, I payed for the wireframe software
You could put the buttons in the top row(s) and use the Freeze Pane option
https://support.office.com/en-us/article/freeze-or-lock-rows-and-columns-3439cfe6-010c-4d2d-a3c9-d0e8ba62d724?ui=en-US&rs=en-US&ad=US
I have an Excel Workbook containing three worksheets. However all sheets seem to be hidden dispite that their visibility is set to xlSheetVisible (Found by looking at the worksheet properties in the VBA editor).
This is what I have tried so far to solve the problem.
Searched Google for help, but all similar problems have been solved by changing the Visibility from xlSheetHidden to xlSheetVisible. But in my case that setting is already set to xlVisible.
By using VBA I have tried to activate a sheet without any result.
By reading this you might have guessed that I am able to see and access the worksheets from the VBA editor.
Despite that looking at the normal Excel userinterface, all buttons are disabled and clicking at the office/file button in the topleft corner doesn't allow me to save the workbook. However if I make any changes to the VBA itself and tries to close the workbook then Excel asks whether or not I would like to save the workbook.
Everything you describe leads me to believe you're hiding the workbook window, not the worksheets. When a workbook window is hidden, all the sheets become hidden and much of the functionality from the toolbar greys out.
In the Visual Basic Editor, you'd also be able to see all of the worksheets and their visibility would be xlVisible, yet they cannot be seen on the screen. This is because they ARE visible, but the window which displays them is not.
Please try clicking the View tab in the toolbar, and then under the Window pane, click Unhide.
If this doesn't work, then try toggling visibility of the workbook.
It sounds like this may really be your problem...
http://vbadud.blogspot.co.uk/2010/08/hide-sheet-tabs-using-vba-hide-excel.html
I'm working on a workbook in Excel 2010 that someone else created (I don't know which version they were using) with a button in it that invokes a macro. There are a lot of macros defined, so I'm right-clicking on it to find out which one it calls, but the context menu doesn't appear. Instead, when I click off, the button gets larger. I can make this happen as many times in a row as I'd like. There is another button the same worksheet that has the same context menu problem, but instead of growing, the text shrinks each time. There is another button that functions normally when I do this.
Growing buttons in Excel is a fairly common issue, with several theories about why this happens, including the use of multiple monitors or using proportional fonts. I have yet to see a definitive answer about this, but there are several workarounds that may work for you.
Delete and re-create the buttons.
Programmatically set the height and width of the buttons when the workbook is opened and when a button is clicked.
Select the button with another object or two on the sheet and group them.
Don't use them at all.
My personal choice is #4. As an alternative to buttons, I either use hyperlinks or shapes with macros assigned to them.
I think you want to enter "Design Mode" in the work book:
You should be able to right-click on the button to see what it does after that.
I have this same issue. I have two Excel workbooks with similar buttons on each. This only happens on one of them, but it happens every time I open that file.
I have found a sort of work-around. I open a blank Excel document, then I open the affected one and the buttons do not change size any more. When I open the second one, I have to drag it into the window with the already-open file. If I double-click on it, it opens in a new window and the problem remains.
I have the same issue sometimes. In my case, I could replicate it 100% on one file but it was inconsistent on an virtually identical file. I also found the size error wasn't permanent -- I could save and reopen the file to restore the button's appearance. I could also create a new window and then discard the damaged window.
For me, the button resized when I accessed the sheet's HPageBreaks collection. I was able to avoid the problem by temporarily changing the window view as follows:
ActiveWindow.View = xlPageBreakPreview
' do pagination stuff using HPageBreaks
ActiveWindow.View = xlNormalView
First of all, thank you for your time and assistance in reviewing this!...
I'm trying to upgrade an Excel VBA workbook to a VSTO Excel Add-in in VB.NET using VS 2010. In the original (i.e.- VBA) version I have a modeless UserForm (called frmMain) that floats on top and is visible at all times while the user is still within the Excel application, but is not visible if the user moves to another window outside of Excel.
For example, within Excel the user can click on any worksheet tab, select any cell, etc. and the UserForm is still visible. This is exactly how I'd like it.
The problem is, that in the new VSTO add-in, I can not get the Windows form to mimic this same behavior.
I use frmMain.Show() to show the form as a modeless form, but the moment the user clicks an Excel worksheet (i.e.- activates a worksheet) the form becomes hidden behind the worksheet.
I can manually Alt-Tab to bring the form back into view, but I need it to always remain in view - floating on top of the Excel worksheets so long as the user hasn't left the Excel application.
I tried various things, including setting the form to TopMost, however, that causes the form to be TopMost everywhere - including outside of Excel. Worse than that, if the user does anything that would normally result in Excel's launching a dialog box (e.g.- closing an open workbook, raising the alert "Do you want to save the changes...") the alert dialog box itself is hidden and inaccessible behind the frmMain form (since the frmMain is TopMost).
How can I get my form to behave in the desired way (i.e.- the same way it did in VBA)?
Thanks!!!
Rob
You should take a look at Custom Task Panes which can be docked or floated within the Excel application. You could also look into the COM interfaces for a lower level connection (see related SO Post) - although Task Panes are really what this type of behavior was intended for.
This method might work (worked for me):
Create a worksheet_selectionChange event handler inside your form class
Put these lines in this event handler:
Dim FormHandle As IntPtr = Me.Handle
Me.Visible = False
Me.Show(NativeWindow.FromHandle(FormHandle))