title: How to create folders & subfolders in Excel using cell value
body: <p>How do I make this code use the value in cell J2 to make a sub folder so when the year rolls around I can just change the date in cell J2 without having to go into the code?</p>
  
  <p>Here is all the  code:</p>
  
  <pre><code>     Sub IfNewFolder()
     Dim R As Range
     Dim RootFolder As String
     RootFolder = "R:\Sales\Quotes (Commercial)\" '&lt;&lt;&lt; CHANGE 1
     For Each R In Range("D1") '&lt;&lt;&lt; CHANGE 2
  
  
         If Len(R.Text) &gt; 0 Then
             On Error Resume Next
             MkDir RootFolder &amp; "\" &amp; R.Text
             MkDir RootFolder &amp; "\" &amp; R.Text &amp; "\2019"
  
             On Error GoTo 0
         End If
     Next R
        End Sub
  </code></pre>
  
  <p>How do I remove <code>MkDir RootFolder &amp; "\" &amp; r.Text &amp; ("\2019")</code> and make it use the value in Cell J2 for that folder name.</p>
  
  <p>Thanks,</p>
  
  <p>Lamar</p>