My vba excel code is using split funtion from a combo box value. It takes an ID (alias=GG) which is a value right of the 6th hyphen.
GG = Split(Sheet1.ComboBox1.Value, "-")(6)
example return good :) (6hyphens) =GG = 414
Butt Road - 2 Tenures - 06 - Practical Completion - 33 Units - Dave Hampton - 414
The code works but not foolproof as does not work when there are only 5 hypens, returning blank.
example return fail :( (5 hypens only) GG=""
'Blaker Court - 1 Tenures - Completed (Outturn) - 14 Units - Sonya Barton - 412'
I can't change any standing data.
I would like a better way in my excel VBA for an if statement to define the string, but can't get it right. I also tried some strreverse but got method object fail.
in SQL the case statement would be .
case when Split(Sheet1.ComboBox1.Value, "-")(6)` = 0 then Split(Sheet1.ComboBox1.Value, "-")(5)` else Split(Sheet1.ComboBox1.Value, "-")(6)` end as GG.
can you help translate this into a vba if statement to define GG?
or even better, to take everything right of final "-".