title: Is there a way to pull out data from csv file by vbscript?
body: <p>I want to create a html page like this:</p>
  
  <p><img src="https://i.stack.imgur.com/hEKMU.jpg" alt="enter image description here"></p>
  
  <p>The <code>File Type</code> drop down box will be 4 csv files containing data output by powershell script like this:</p>
  
  <p><img src="https://i.stack.imgur.com/2eRFC.jpg" alt="enter image description here"></p>
  
  <p>Is there a way to use vbs to pull out rows from csv file based on <code>year</code> and <code>month</code> drop down lists selection? for example creation time or lastwrite time.</p>
  
  <p>or if there is any better idea to do this?</p>
  
  <p>What I have now looks like this, I have to enter a string to search, I would like to use drop down list ......</p>
  
  <p><img src="https://i.stack.imgur.com/gcMSb.jpg" alt="enter image description here"></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;TEST&lt;/title&gt;
  
  &lt;/head&gt;
  
  &lt;script language="VBScript"&gt;
      'Closes all elements of program in an orderly fashion.
      sub sub_exit
          Self.Close()
      end sub
  
      'this sub does all the work
      sub sub_query_database_OnClick()
          If UserInputQuery.Value = "" Then
              MsgBox "Please enter a search term."
              UserInputQuery.Focus
              Exit Sub
          End If
          outputArea.Value = ""
          'Declare all variables
          Dim strfind
          Dim strComputer
          Dim testValue
          Dim objExcel
          Dim objWorkbook
          Dim intRow
          Dim intColumn
          Dim strExcel
          Dim matchArray(10)
          Dim intCount
          Dim outputBox
  
          'initialize all variables
          strComputer = "."
          strfind = UCase(UserInputQuery.Value)
          strFile = "C:\Work\Web\Data\nxdata.csv"
          strExcel = UCase(strFile)
          Set objExcel = CreateObject("Excel.Application")
  
          'refresh database
          objExcel.Visible = False
          objExcel.Application.DisplayAlerts = false
          Set objWB = objExcel.Workbooks.Open(strExcel,2,False)
          Set objSheet = objWB.Sheets(1)
          objWB.RefreshAll
  
  
  
          Dim FoundCell
          Dim LastCell
          Dim FirstAddr
          Dim strRange
  
          strRange = "a3:E2000"
          intCount = 0
  
          With objSheet.Range(strRange)
              Set LastCell = .Cells(.Cells.Count)
          End With
          Set FoundCell = objSheet.Range(strRange).Find(strfind, LastCell)
          If Not FoundCell Is Nothing Then
              FirstAddr = FoundCell.Address
          End If
          Do Until FoundCell Is Nothing
              intCount = intCount + 1
              outputArea.Value = outputArea.Value &amp; objSheet.Cells(FoundCell.Row, 2).Value &amp; " " &amp; objSheet.Cells(FoundCell.Row, 5).Value &amp; " " &amp; objSheet.Cells(FoundCell.Row, 6).Value &amp; vbCr
              Set FoundCell = objSheet.Range(strRange).FindNext(FoundCell)
              If FoundCell.Address = FirstAddr Then
                  Exit Do
              End If
          Loop
          If intCount = 0 Then
              MsgBox "No occurrences of " &amp; strFind &amp; " were found."
          Else
              MsgBox intCount &amp; " occurrences of " &amp; strFind &amp; " were found."
          End If
  
          objWB.Saved = True
          objWB.Close True
          'excel program is closed.
          objExcel.Quit
      end sub
  &lt;/script&gt;
  
  &lt;body&gt;
  &lt;!--Here we have a textfield for input, an input button, a textfield for output, and an exit button.--&gt;
  &lt;input type="text" name="UserInputQuery" size="50"&gt;
  &lt;input type="button" value="Run Query" name="sub_query_database"&gt;&lt;p&gt;
  
  &lt;input type="button" value="Exit" name="exitButton"  onClick="sub_exit"&gt;&lt;p&gt;
  &lt;br&gt;
  &lt;textarea name="outputArea" rows="50" cols="225"&gt;&lt;/textarea&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;   
  </code></pre>