Simple Excel sprintf visual basic (vba) macro

Simple Excel sprintf visual basic (vba) macro.
Example:  “=printf(“Some text '%s', more text: '%s'”, A1, A2)”

Public Function Printf(mask As String, ParamArray tokens()) As String
    Dim i As Long

     For i = 0 To UBound(tokens)
          mask = Replace$(mask, “%s”, tokens(i), , 1)
     Next

     Printf = mask

End Function

Tags: , , ,

2 Responses to “Simple Excel sprintf visual basic (vba) macro”

  1. Willian Leitzel September 17, 2015 at 10:07 #

    its great as your other articles : D, appreciate it for putting up.

  2. oakley sunglasses wholesale September 19, 2015 at 02:26 #

    Thanks a lot for sharing!

Leave a Reply