title: VB Excel Macro Millisecond Timing
body: <p>I am trying to write a macro in VB for an Excel spreadsheet which is executed in specific intervals which are defined by a value (in Hz) contained in the spreadsheet itself. My problem is that the code I found for accomplishing an automatic macro in this way appears to only allow for second accuracy, so any frequencies above 1Hz are not possible. I would like to be able to get up to around 10Hz if possible, which would require millisecond accuracy.</p>
  
  <p>I am new to VB, so I do not know much about it. Here is the code:</p>
  
  <pre><code>Sub Macro2()
      Range("K1").Select
      Dim f As Single
      f = ActiveCell.Value
      Dim t As Integer
      t = 1 / f
      dTime = Now + TimeSerial(0, 0, t)
      Application.OnTime dTime, "Macro2"
      Range("J1").Select
      Dim c As Integer
      c = ActiveCell.Value
      c = c Xor 1
      ActiveCell.Value = c
  End Sub
  </code></pre>
  
  <p>Is there any way to get Millisecond accuracy using this method?</p>