Grid control that can be placed on userform? - excel

Does anyone know of a grid control that can be placed on an Excel UserForm, preferably something that is capable of displaying the content of a ADODB Recordset?

In VB window using 'Tools'->'Additional Controls' menu, there may be DBGrid control; check it.

In the VB window, using 'Tools->Additional Controls, there is a 'Microsoft Office Spreadsheet 11.0' control that is very powerful. This is true for Excel 2010, at least. Don't know about more recent versions.

Just throwing this out there for anyone that might be interested. I too as looking for a way to display what looks like a grid on a userform. Since I'm working on a shared program with different users having different versions, I shied away from the "Additional Controls.
Very simply, what I did was throw a number of labels into a frame, got rid of the borders, separated them with just the tiniest space in between and set the back color of the frame to a darker color. The result is below.

Related

Can I insert an item with a specific color in a Listbox?

I'm developing an application with VBA in Excel 2013. I have a ListBox with items and I want to give each item a specific color depending on a criteria, I searched on the net but it says that it is impossible to do so, is that true?
I tried to use the listview (Microsoft ListView Control) but it doesn't show on the extra controls in the userform.
Does anyone know how to do give each item a specific color depending on a criterion using a Listbox if possible?
You cannot change the colour of individual items in an Excel listbox.
There are alternative ways you can achieve a similar result:
Use the ActiveX ListView control like examples here or here or here.
You can dynamically create an HTML Table and display that in a web browser control.
You can manipulate Excel cells to look and act like a listbox.
Your best best might be the ListView control but it could take some fancy footwork.
More Information:
MSDN : Using the ListView Control (Visual Studio)
MSDN : Using ActiveX Controls on Sheets
MSDN : ListView Properties
If you want to customize a ListBox in a UserForm, then you may use this DesignListBox
https://github.com/balin77/ExcelDesignListBox
It allows you to change any color, FontSize or Style.

Visual Basic for Applications Animated text

when I open my excel, macro command run automatically and show "welome".But i want to design it little bit.Is there any way i can change its colour size or text box. below my screen shot. [Its not utmost important but I love to know can i animated this text.]
IMAGE LINK
https://msexcel-analysistabs1.netdna-ssl.com/wp/wp-content/uploads/2013/01/run-a-macro-automatically.png
Are you just calling a standard msgbox in VBA? If so, instead of calling a msgbox, you can create an actual UserForm in Excel VBA. From there, place a label in the "box" and you can format the font in a variety of ways: colors, size, text font, etc.
You cannot do any "fun" animations as far as I know. But you can definitely change the font size and color!
Here is an example (I'm not the most creative person)
You do this under the VBA Project Explorer -> Insert -> Userform. From there you add Labels/Buttons/Whatever objects you would like, and resize the form if you so choose. Then in your module/macro, you call this form instead of using a msgbox.
As far as changing the color and size of the text, Yes, you need to create a UserForm and create the 'Welcome' screen as a custom form instead of using VBA's msgbox.
In VBA, right click on the workbook in the Project Explorer.
Select Insert->UserForm.
Design how you'd like the Welcome screen to display.
In ThisWorkbook's Workbook_Open() sub, put UserForm.Show() to display the custom welcome message when the workbook first opens.
As far as animating said text, Not really. There are some convoluted workarounds using an embedded webbrowser object in order to render a custom animated text javascript file. It is full of 'Potential Risk' notifications for the user and really doesn't look very good. Sorry to burst your bubble :).

How do I allow user to select, but not edit, text in an excel userform control whose width is smaller than the text?

Context
I want the user to review some selections they made earlier. So I display some text describing each selection on a separate control in a userform. Some of the text on the controls is long, extending beyond the width of the control. This is fine; I just want the user to be able to see all of the text without being able to edit it. To do this, I use textboxes that are "Locked" (i.e. not editable) but "Enabled" (i.e. selectable). This way, they can just click and either mouse-drag or arrow-key over to scroll through all the text.
Problem
The (small, aesthetic) problem is that when the user clicks in one of the textboxes, they get a blinking cursor, which is misleading as that is normally associated with an editable textbox.
Possible solutions
Ideally, there would be some way of removing the blinking cursor, while still allowing selection but not edition. However, I'm open to other alternatives that don't have to do with changing the width, or having a scrollbar (the textbox is too short to fit a scrollbar). The best alternative I have so far is changing the background color to a gray to make it slightly more clear that it's not editable.
P.S. I'm very familiar with VBA, so if that's part of the solution, I'm cool with that.
Thanks all!
I had a similar issue, and solved it by using these instructions to create a hidden textbox that the cursor automatically appeared in (invisible to the user).

Is there RefEdit control equivalent in Libre Calc?

Does anyone know what is Libre Calc’s equivalent for Excel’s RefEdit control? All other Excel UserForm controls seem to have corresponding controls for Libre Dialog forms. If there isn’t one, is it possible to tweak some other control (like Combo Box) into behaving like reference input box?
For those who don’t know RefEdit, it is the control that lets the user specify range address. More detailed explanation is e.g. in How to code a .NET RefEdit Control on Gabhan Berry’s Excel Programming blog or in KB213776.
Yes, there is such a possibility - you must use XRangeSelectionListener
By setting different RangeSelectionArguments you will get different picker behavior.
An example of a macro that is shown in this animation is here RefEdit_Demo.ods

Calendar in Excel shrinks

I am using Excel VBA. I added a calendar control so that users can pick the date from the calendar. I noticed something that whenever the excel file is opened the Calendar shrinks smaller and smaller. Now I can see that the calendar will disappear after reopening the file several times.
Any ideas? please help
Thanks,
You can get around this by adding
Calendar1.Width = 165
Calendar1.Height = 165
to your code (right click on control and "see code". I've used 165 (millimeters on my system), but you can check the properties of the control, once you have it the size you want, to get the values.
I found the opposite worked for me (Excel 2007) I had exactly the same problem but only when I changed the format to "move or resize with cells" that the calendar stayed the same size after file save and close. Your answer put me on the right path though, thanks!
I've seen this behaviour before with other controls. I think it's a bug that is linked to the control's resize setting, even though cells aren't being resized.
Try the following in design mode:
Right-click control and select Format Control
In Properties tab, select 'Don't move or size with cells'

Resources