title: Create folder and moves all the xlsx file in the newly created folder
body: <p>I am new to VBA MACRO I want the macro to create a folder (SubFolder) then moves all the file to the newly created folder.</p>
  <p>My codes</p>
  <pre><code>Sub create_move()
  
  'Variable declaration
      Dim sFolderName As String, sFolder As String
      Dim sFolderPath As String, oFSO As Object
      Dim fromdir As String
      Dim todir As String
      Dim flxt As String
      Dim fname As String
      Dim fso As Object
         
      'Main Folder
      sFolder = &quot;C:\Main\&quot; 'Main Folder where macro excel is present
      
      'Folder Name
      sFolderName = &quot;POL &amp; POD Files&quot; &amp; &quot; &quot; &amp; &quot;-&quot; &amp; &quot; &quot; &amp; Format(Now, &quot;DD-MM-YYYY&quot;)
      
      'Folder Path
      sFolderPath = &quot;C:\NewFolder\&quot; &amp; sFolderName 'New Folder
          
      'Create FSO Object
      Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
      
      'Create Folder
      MkDir sFolderPath
      
  'Move files
  
  fromdir = &quot;C:\Users\chariab\Desktop\POL-POD AutoExp\Extracted Files\&quot;
  
  todir = &quot;sFolderName&quot; &amp; &quot;sFolderPath&quot; ' Newly created folder name and path
  
  flxt = &quot;*.xlsx&quot;
  
  fname = Dir(fromdir &amp; flxt)
  
   If Len(fname) = 0 Then
   MsgBox &quot;All Excel Files Moved&quot; &amp; fromdir
   
  Exit Sub
  End If
  
  
  Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
  
  fso.MoveFile Source:=fromdir &amp; flxt, Destination:=todir
  
  End Sub
  </code></pre>
  <p>This macro creates folder but does not move the files in it I get run time error 76 Path not found. When I debug I get an error on this line <code>&quot;fso.MoveFile Source:=fromdir &amp; flxt, Destination:=todir&quot;</code></p>
  <p>My idea was like to first create a new folder so for that I made initial coding to create a new folder and then to move the files in that newly created folder so I gave &quot;their = the variable name and path which I used to create the folder&quot; but this is not working this code is creating new folder but not moving the files in them and getting error in this line &quot;fso.MoveFile Source:=fromdir &amp; flxt, Destination:=todir&quot; saying path not found.</p>
  <p>Some1 please help....</p>