title: How to assign code from a function to a button?
body: <p>How do I call this function with the click of a button.<br />
  Is there a way to assign this function to a button?</p>
  <pre class="lang-vb prettyprint-override"><code>Function GetFolder() As String
      Dim fldr As FileDialog
      Dim sItem As String
      Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
      With fldr
          .Title = &quot;Select a Folder&quot;
          .AllowMultiSelect = False
          .InitialFileName = Application.DefaultFilePath
          If .Show &lt;&gt; -1 Then GoTo NextCode
          sItem = .SelectedItems(1)
      End With
  NextCode:
      GetFolder = sItem
      Set fldr = Nothing
  End Function
  </code></pre>