Jump to content

Excel and ComboBox


Recommended Posts

I founded how to do that combobox in H30 with datas from D5:D8. Here's a sample code:

#include <ExcelCOM_UDF.au3>

;Enum XlDVType

Const $xlValidateInputOnly = 0

Const $xlValidateWholeNumber = 1

Const $xlValidateDecimal = 2

Const $xlValidateList = 3

Const $xlValidateDate = 4

Const $xlValidateTime = 5

Const $xlValidateTextLength = 6

Const $xlValidateCustom = 7

;Enum XlDVAlertStyle

Const $xlValidAlertStop = 1

Const $xlValidAlertWarning = 2

Const $xlValidAlertInformation = 3

;Enum XlFormatConditionOperator

Const $xlBetween = 1

Const $xlNotBetween = 2

Const $xlEqual = 3

Const $xlNotEqual = 4

Const $xlGreater = 5

Const $xlLess = 6

Const $xlGreaterEqual = 7

Const $xlLessEqual = 8

Const $xlTrue = 1

Const $xlFalse = 0

$oExcel.Activesheet.Range("H30").Select()

$oExcel.Activesheet.Range("H30").Validation.Add($xlValidateList,$xlValidAlertStop,$xlBetween,"=$D5:$D8");, AlertStyle:=xlValidAlertInformation, Minimum:="5", Maximum:="10"

$oExcel.Activesheet.Range("H30").Validation.InputMessage = ""

$oExcel.Activesheet.Range("H30").Validation.ErrorMessage = ""

$oExcel.Activesheet.Range("H30").Validation.IgnoreBlank = $xlTrue

$oExcel.Activesheet.Range("H30").Validation.InCellDropdown = $xlTrue

$oExcel.Activesheet.Range("H30").Validation.ErrorTitle = ""

$oExcel.Activesheet.Range("H30").Validation.InputTitle = ""

$oExcel.Activesheet.Range("H30").Validation.ShowInput = $xlTrue

$oExcel.Activesheet.Range("H30").Validation.ShowError = $xlTrue

Edited by TomTJ
Link to comment
Share on other sites

  • 2 years later...

$oExcel.Activesheet.Range("H30").Select()

$oExcel.Activesheet.Range("H30").Validation.Add($xlValidateList,$xlValidAlertStop,$xlBetween,"=$D5:$D8");, AlertStyle:=xlValidAlertInformation, Minimum:="5", Maximum:="10"

$oExcel.Activesheet.Range("H30").Validation.InputMessage = ""

$oExcel.Activesheet.Range("H30").Validation.ErrorMessage = ""

$oExcel.Activesheet.Range("H30").Validation.IgnoreBlank = $xlTrue

$oExcel.Activesheet.Range("H30").Validation.InCellDropdown = $xlTrue

$oExcel.Activesheet.Range("H30").Validation.ErrorTitle = ""

$oExcel.Activesheet.Range("H30").Validation.InputTitle = ""

$oExcel.Activesheet.Range("H30").Validation.ShowInput = $xlTrue

$oExcel.Activesheet.Range("H30").Validation.ShowError = $xlTrue

Hey man great post.....I'm trying to go the other direction. Do you know of a way to retrieve all the enteries ComboBoxes/Dropdown Box?

Link to comment
Share on other sites

Hey man great post.....I'm trying to go the other direction. Do you know of a way to retrieve all the enteries ComboBoxes/Dropdown Box?

Ok I sort of figured it out....so to get the formula and therefore the range in the Validation cell then you would use.

MsgBox(0,"",$oExcel.ActiveSheet.Range("D3").Validation.Formula1)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...