Change Drop-Down Value in Excel-List with AppleScript

Hi there

I have an excel-sheet with a drop-down-menu with various values. (for example “A,”,B" and "C).
Is there a way to change the value of the drop down? (for example from “A” to “C”? ) with Applescript?

Thank you very much

Kind regards
Marth

Hi Marth,

Can you give us a little more detail on how you created the drop-down?
Is it picking up the values from a range of cells?

Thanks.

Hi TecNik

Thank you for your answer.
Of course here are 2 screenshots, of the Excel-Sheet with the DropDown. The values are defined in “Date validation”. My question is, is there a way to change the value-selection in this drop down.

Example; I would like to change the Value from “Value1” to “Value3”.

Thank you very much
Kind regards

Marth

You can just set the value of such a cell to one of the values from the dropdown list, and the list will remain intact.
I’m assuming setting a value not in the list will destroy the validation - I never tested that.

tell application "Microsoft Excel"
	set value of column x of row y to "some_list_value_here"
	-- or any other cell reference that you prefer
end tell

Hi alastor993

Thank you very much for your help. This works great!
If I try to set an value, which is not in the drop down, I get an error.

Cheers
Marth

To catch that error you could wrap the line that sets the value in an ‘on error’.


try
		-- set the value here...
	on error
		-- do something if you get an error
end try

HTH