ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change/cycle cell entry to next option from validation list (macro (https://www.excelbanter.com/excel-programming/351476-change-cycle-cell-entry-next-option-validation-list-macro.html)

Neil Goldwasser

Change/cycle cell entry to next option from validation list (macro
 
I was wondering if anybody knows a macro that could be used with cells that
are limited to containing values from a data validation list, so that when
the macro is run, the cell entry for whichever cell(s) are selected changes
to the next one in the list?

E.g. If the data validation list contains the following values (in order):
red
blue
yellow
green

If a cell is selected that currently displays "red" and the macro is run on
that selection, then the cell will change to display "blue". If it is run
again it will change to "yellow" etc... If the current value is the last one
in the list (in this example, "green") and the macro is run, the fiirst entry
is taken (i.e. it would cycle back to "red").

If the cell was originally blank, then the first value in the drop-down list
would be entered.

If possible, could the macro work on a selection rather than just a single
cell, so more than one cell could be changed at a time?

The possible values to choose from would ideally be ones just entered
straight into the "source" section of the "data validation" dialog box, but
if it is easier I could use a named range as the source (e.g. inserting the
named range "colours"), or a cell reference, e.g. A1:A4.

If possible, it would be great to have a generic macro that could be used
with any cell containing a validation list (i.e. one that will work not just
with the colours example I have given, but so that I could use it again with
other cells, e.g. an "age" cell with a different validation list etc...) but
I do not know if this is possible. I could always try to adapt the code for
future examples if I can understand how it functions (e.g. what the
parameters, references etc... used are).

Again, if possible, the ideal situation would be to be able to use a similar
macro to cycle through the list backwards.

I'm afraid I don't know enough to know if this is possible, but any ideas
would be greatly appreciated.

Many thanks in advance, Neil


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com