Hi all,
On my spreadsheet I am using data validation to enter values into a sheet.
The data validation references a list (a named excel area) containing the following formulae
=X6&" - "&Y6
This produces a result of e.g. "1 - Invoice" being the concatenation of the values in the 2 fields X6 (=”1”) and Y6 (= “Invoice”). This full concatenation then appears in the validation dropdown list.
I have vb code to select just the value "1" and put it in the spreadsheet.
Essentially the code is:
Private Sub Worksheet_Change(ByVal Target As Range)
Target.Value = Left(Target.Value, InStr(1, Target.Value, " ") - 1)
End Sub
Basically this is just a way of showing 2 columns of data while only 1 gets input to the spreadsheet and it work fine.
The problem is if I try to manually type a value into a cell with the above mentioned validation, I get a data validation error. It is only possible to enter a value in the cell using the drop down list.
I can sort of see why this is happening:
The value (e.g. “1”) entered is compared to the validation list value ("1 - Invoice"), the code sees they are different and gives an error.
Is there any way to manually enter a value into the cell without getting the validation error?
I am reasonably good at problem solving minor vb problem but this one has me stumped.
I've seen this problem come up before but I've not seen a solution.
Any help would be much appreciated.
Bookmarks