title: Color Excel based on cell value in VBScript
body: <p>I have one VBS which convert my csv to excel.
   Now my CSV there are some characters like "!"
  I want to color Yellow on those cell which are having that character after converting to excel.</p>
  
  <p>Sample.CSV :</p>
  
  <pre><code> Name,Location,Phone,Comment1,Comment2
   "ABC","Pune",123,"Expert Value","! Easy"
   "XYZ","Kol",567,"! Expert value",Easy"
  </code></pre>
  
  <blockquote>
    <p>Requirement : after converting to Excel, I need E2 and D3 Cell should
    be as Yellow</p>
  </blockquote>
  
  <p>MyScript.vbs : which needs two argument to execute</p>
  
  <pre><code>cscript C:\Test\MyScript.vbs \\C:\Test\Sample.CSV \\C:\Test\Sample.xlsx
  </code></pre>
  
  <p>Here is the original script</p>
  
  <pre><code>'======================================
  ' Convert CSV to XLS
  '
  ' arg1: source - CSV path\file
  ' arg2: target - Excel path\file
  '======================================
  
  srccsvfile = Wscript.Arguments(0)  
  tgtxlsfile = Wscript.Arguments(1)  
  
  'Create Spreadsheet
  'Look for an existing Excel instance.
  On Error Resume Next ' Turn on the error handling flag
  Set objExcel = GetObject(,"Excel.Application")
  'If not found, create a new instance.
  If Err.Number = 429 Then  '&gt; 0
    Set objExcel = CreateObject("Excel.Application")
  End If
  
  objExcel.Visible = false
  objExcel.displayalerts=false
  
  'Import CSV into Spreadsheet
  Set objWorkbook = objExcel.Workbooks.open(srccsvfile)
  Set objWorksheet1 = objWorkbook.Worksheets(1)
  
  'Adjust width of columns
  Set objRange = objWorksheet1.UsedRange
  objRange.EntireColumn.Autofit()
  'This code could be used to AutoFit a select number of  columns
  'For intColumns = 1 To 17
  '    objExcel.Columns(intColumns).AutoFit()
  'Next
  
  'Make Headings Bold
  objExcel.Rows(1).Font.Bold = TRUE
  
  'Freeze header row
  With objExcel.ActiveWindow
       .SplitColumn = 0
       .SplitRow = 1
  End With
  objExcel.ActiveWindow.FreezePanes = True
  
  'Add Data Filters to Heading Row
  objExcel.Rows(1).AutoFilter
  
  'set header row gray
  objExcel.Rows(1).Interior.ColorIndex = 15
  '-0.249977111117893
  
  
  'Save Spreadsheet, 51 = Excel 2007-2010 
  objWorksheet1.SaveAs tgtxlsfile, 51
  
  'Release Lock on Spreadsheet
  objExcel.Quit()
  Set objWorksheet1 = Nothing
  Set objWorkbook = Nothing
  Set ObjExcel = Nothing
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Eh5vs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Eh5vs.jpg" alt="enter image description here"></a></p>