I am trying to learn and implement a Function in VBA with an optional argument. I am trying to seperate values in a string given a character or substring to seperate.
Private Function SeperateString(MainString As String, Seperator As String) As String { // Body } Eg: I want to seperate "1-2-3-4-5" using seperator "-" or "1/2/3/4/5" using seperator "/".
I will write the logic using Instr and other functions. My doubt is I want to pass a seperator so I don't need to write a seperate function for each and want "-" to be default if nothing is passed. Can I do that?