Reputation: 477
I have a YAML file which I am reading using VBA Excel plugin. I am getting a String of each line. I need to count the number of empty spaces in the front of the first line so that it will be a marker to find the next key. Let me know how to do that.
Upvotes: 2
Views: 5098
Reputation: 1
Function Empty_Space(Str_Input)
Empty_Space = Len(Str_Input) - Len(Application.WorksheetFunction.Substitute(Str_Input, " ", ""))
End Function
I also tried above one was not working. You can try this one. It will work to counts space.
Upvotes: 0
Reputation: 43595
Option Explicit
Function empty_spaces(str_input)
empty_spaces = Len(str_input) - Len(LTrim(str_input))
End Function
harun24hr, your answer does not work with " My String " and similar.
Upvotes: 2