Excel 2011 Mac VBA Combobox value - excel

In excel 2011 on the mac, I have a spread sheet with two controls. A combobox and a button. the combo box is named Crops and i want to access the value of that box when clicking the button.
The obvious Crops.Value that would work in windows office does not seem to work and i get an error saying the Crops object is missing.
Is this (simple) task possible with VBA on the Mac?

ok solved it. Active X objects do not work on the mac. You have to use Forms elements and then if you want to access the value of a dropdown this is the VBA code. Hope it helps someone else.
assuming Crops was the combobox, Itm will have the value.
With ActiveSheet.DropDowns("Crops")
Itm = .list(.ListIndex)
End With

Related

Changing the text of an Options Button on Excel for Mac 365

I have made a workbook on Excel for Windows and I am now trying to get it to work on Excel for Mac. (I have Office 365, so I have the most current versions of Excel on both computers.) For the most part it works fine, but there are a few things that aren't working. One bit that is really confusing me is changing the text of some Option Buttons that I have on a few different sheets. (Based on some input, the text of the Option Buttons needs to change.)
In Excel for Windows, here's how I change the text:
ThisWorkbook.Sheets("Sheet1").Shapes("OptionButton1").TextFrame.Characters.Text = "New Text"
The above works whether or not Sheet1 is the ActiveSheet, and whether or not OptionButton1 is in a column that is currently hidden.
That line of code does not work on Mac. For it to work, I have to split it up, and introduce a Select command. I also have to Activate the sheet.
With ThisWorkbook.Sheets("Sheet1")
.Activate
.Shapes.Range(Array("OptionButton1")).Select
Selection.Characters.Text = "New Text"
End With
It's annoying that after the code runs, one Option Button is selected on each page.
Another annoying thing -- I have to make sure the column that the Option Button is in is not hidden. I assume this is because I am being forced to select the Option Button itself, and it can’t do that if it’s in a hidden column?
I would love to NOT have to select the Option Button at all, but I can't figure out any other code to change the text. To be honest, the only reason I was able to come up with this code is because I recorded a macro of myself actually doing it.
If anyone knows about Excel for Mac and could help, please let me know. Thanks!
I would add ActiveSheet to the code to prevent all objects named Option Button 1 from being selected at the same time
ActiveSheet.Shapes.Range(Array("Option Button 1")).Select
Hiding columns does not affect option buttons' visible property on Mac or Windows. Option buttons have their own hidden/visible property.
Using this syntax works on both Mac and Windows, so why not go with it intstead of the older way?

Excel activex combo box disappear

working in excel 2010 sheet & i have a few combo box's around 20 & i right click on of them then suddenly all of them are disappeared but there VBA code and properties still exist so please can some one help me.
the visible is set to fulse
i found the problem in the properties of the combobox, height and lift of properties size i just adjust them and they appear again.

Date picker ActiveX excel VBA not responding when created automatically

Dear (vba) programmers,
I am building a dynamic filter in excel (with vba and ActiveX controls).
I would like to use the Microsoft Date and Time Picker Control, Version 6.0 in Excel 2010.
When I generate a drop down calendar with:
Set OLEObj = Sheets("Blad3").OLEObjects.Add(ClassType:="MSComCtl2.DTPicker.2", Link:=False, DisplayAsIcon:=False, Left:=10, Top:=10, Width:=123, Height:=40)
It is placed correctly, but it doesn't function. When I toggle developers mode on and off it functions all of the sudden. This seems like a bug to me or do I have to activate the object or something like that??
I have the same problem as the "first strange thing" of:
http://www.ozgrid.com/forum/showthread.php?t=47290
Hopefully there is someone with the answer.
Thank's in advance!
Yes.. This is a problem with mscomctl control in Windows. If the mscomctl.ocx is not registered in system32 folder then your Excel won't support that date picker.
You can create customized Date Picker and that won't need any such control as it will be totally a userform with different objects.
Check out this video to see how it looks like:
How to Create This?
Create a excel calender in a excel sheet using formulas. Check this video to see how to do it.
Then, create a Userform. Add Labels for each day and headers.
Set caption of these Labels to cell reference.
On label click event - change bgcolor of that label and save value in it's caption.
Rest it is self explanatory if you watch both videos carefully.
If you don't want to create your own date picker then you need to put mscolctl.ocs in system32 folder and execute batch command to execute it.
Once it is there click START>RUN and type REGSVR32 MSCOMCTL.OCX

Excel combo box

I have a workbook that has a combo box list in it and works fine until I try to share
the book, then it stops working. I have since found out that this is how Excel is set up!
I have a validation list that works but will only show 8 lines whereas the combo will show all 22 lines at once, which is what I was trying to achieve.
Can I use a form control to work around this and if so how do I do it ?
I have just tested this, adding an ActiveX Combo-box to a sheet, linking it to a list of cells and sharing the workbook, the Combo-box drop down is unaffected.
If you are trying to insert a combo-box to an already shared workbook, then the insert menu will be greyed out, to do this you must open the workbook in exclusive mode by going to Review > Share Workbook and deselecting the share tick box.
Once you have it open in exclusive mode you can then add in the combo-box and re-share.

Excel 2007 Combo Box - Developer Ribbon vs. VBA Module

Could someone please explain to me the difference between the combo box that's available via the Developer Ribbon in Excel 2007 vs. the Combo Box control that's in the VBA editor? I cannot get this simple line of code to work using the Developer combo box:
MsgBox Combo1.Value
I've tied it to the change event and it seems to be syntactically correct (I'm not a VBA coder by any stretch).
Is the Developer Ribbon version some bastardized craptastic Microsoft shortcut?
What I'm trying to do is populate a second combo box based on the selection of the first combo box. I'd rather not build a case statement for every possible selection. Is this possible using the Developer ribbon version?
You are talking about the Insert button on the Developer tab correct? From that button you can add an ActiveX control or Form control. You're better off using the form controls if your new to programming as they will behave more in line with any Excel VBA reading you've done and the help file. With the Form controls you can right click and choose 'View Code' and/or 'Rename Control and Code'. Renaming the control allows you to address it in VBA however you like. e.g. - Combo1.value or myFavoriteCombo.value
That being said, to answer your question directly, be sure you know the controls full name. If you used a form control and it was the first one you put on the sheet it will be named ComboBox1. To get to the combobox's properties you have to walk through it's 'parent' sheet.
i.e.
MsgBox Sheet1.ComboBox1.value (using the sheet's code name)
or
MsgBox Worksheets("SheetName").ComboBox1.value (using the sheets name as it appears on the Excel tab)

Resources