title: Getting type mismatch error in replace function in vba
body: <p>My vba code is to replace current time and date to 4_17_2014 8_09_00 PM format</p>
  
  <p>But i am getting type mismatch error while running below VBA code</p>
  
  <pre><code>Function Current_Date_Time_Stamp()
  
  Dim CurrTime As Date
  
  CurrTime = Now
  MsgBox Now
  CurrTime = Replace(CurrTime, "-", "_")
  MsgBox CurrTime
  CurrTime = Replace(CurrTime, ":", "_")
  Current_Date_Time_Stamp = CurrTime
  
  End Function
  </code></pre>
  
  <p>Can anybody help me why i am getting error</p>