title: Vba check if file starts with values from list and if not kill it
body: <p>In my never ending story to learn VBA I am trying to create a macro that deletes files based on the files starting characters and unsure how to proceed.</p>
  <p>I have an excel file with numbers in column a ,these numbers are either 4,5 or 6 digits.
  I have a file folder with files which may or may not start with these digits from a range from excel file.  These files in folders are of different types<br />
  But I reckon this may not be an issue still,the naming convention is as follows :  ie.   4563_listofitems.pdf,65475_skusdec.doc etc.</p>
  <p>My goal is to loop through files and check if the starting characters of the file are on included in the A range of the excel sheet,if so (there may be up to 6 files starting with such number) create a folder named with the found starting characters and move the files starting with these characters into the folder,else if file doesn't start with fixed characters from the list then just delete (kill) that file.  My issue is idk how to check the files names against the  list.</p>
  <p>My code as now for looping trough</p>
  <pre><code>Sub loopf
  
  Dim filen as variant
  Filen =dir(&quot;c:\test\&quot;)
  While filen &lt;&gt;&quot;&quot;
  
  If instr(1,filen,10000)=1 then
  'Here I want check against the values from range but unsure how ,should I somehow loop through the range ?
  
  
  Filen=dir
  End if
  Wend
  End sub
  </code></pre>