Since JSON is a subset of YAML, I would like to say that if JSON output is possible, YAML output is possible, but you want to output YAML-like(?) YAML.
Like JSON, YAML is just a string, so it's not impossible to output.You just need to combine strings.
A very simple example would be, for example:
Sub ToYAML()
Dimr As Integer, c As Integer
Dim result As String
For = 2 To 6
result=result&"-"
Forc=1 To 3
result=result&Cells(1,c).Value&":"&Cells(r,c).Value&vbCrLf&"
Next c
result=Left(result, Len(result)-2) 'Remove the excess " " at the end
Next r
Debug.Print result
End Sub
The range, whether it is Value or Text, the presence or absence of a quote, the output method, etc. are not mentioned in the question, so it is appropriate.Adjust as needed.
© 2024 OneMinuteCode. All rights reserved.