G'day,
Within a sreadsheet I have created, much data is validated by a list that is sourced from cells within the same spreadsheet (with an in-cell drop-down menu). What I am attempting to do is allow the user to, if necessary, add further items to the validation source list as required. This is simply a matter of entering a value into a cell in my spreadsheet and altering the source range for validation to include this new data. I am in the process of writing a macro to semi-automate this task by acquiring the user's desired addition to the source list via a message box and then adding it to the source list in a cell, and then finally updating the data validation settings to extend the source range for the cells to be validated. Effectively what is happening is that each time a new addition is made, the range of the source is increasing. My problem occurs though, in that I don't know how to make the source range "variable". An example of the code used to enter in the source of the validation list in VBA is:
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$S$4258:$S$4268"
Where Formula1: quotes the source range.
I would like to make the range variable (to allow for additions as the list increases), so that the second co-ordinate in this formula is a variable one. Within my macro, I have a variable that describes the total length of the source list but this cannot be entered into the formula describing the source range (Formula1), since it is obviously not constant! However, when I have tried to insert my variable into this formula, I only get errors. Is there any way that I might be able to get around this problem so that I can describe a variable source range?
I hope I have provided enough information, as this is my first post. Any help that anyone could provide would be greatly appreciated!
Within a sreadsheet I have created, much data is validated by a list that is sourced from cells within the same spreadsheet (with an in-cell drop-down menu). What I am attempting to do is allow the user to, if necessary, add further items to the validation source list as required. This is simply a matter of entering a value into a cell in my spreadsheet and altering the source range for validation to include this new data. I am in the process of writing a macro to semi-automate this task by acquiring the user's desired addition to the source list via a message box and then adding it to the source list in a cell, and then finally updating the data validation settings to extend the source range for the cells to be validated. Effectively what is happening is that each time a new addition is made, the range of the source is increasing. My problem occurs though, in that I don't know how to make the source range "variable". An example of the code used to enter in the source of the validation list in VBA is:
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$S$4258:$S$4268"
Where Formula1: quotes the source range.
I would like to make the range variable (to allow for additions as the list increases), so that the second co-ordinate in this formula is a variable one. Within my macro, I have a variable that describes the total length of the source list but this cannot be entered into the formula describing the source range (Formula1), since it is obviously not constant! However, when I have tried to insert my variable into this formula, I only get errors. Is there any way that I might be able to get around this problem so that I can describe a variable source range?
I hope I have provided enough information, as this is my first post. Any help that anyone could provide would be greatly appreciated!