title: Delete set of lines between two strings in Excel VBA
body: <p>I have a task to read a bunch of notepad files and in each of the file, I need to delete the set of lines which are present in between the strings "dynamics" and "end dynamics" and also delete those two strings as well. </p>
  
  <p><img src="https://i.stack.imgur.com/rsQhg.jpg" alt=""></p>
  
  <p>The attached image shows the part which needs to be removed, wherever it has occurred (dynamics to end dynamics &ndash; any content can be present with these two boundaries) in that text file.</p>
  
  <pre><code>L3.3
  
  resizeText 1
  zoomLines 0
  zoomArrows 0
  doLasso 1
  opaqueMove 1
  selectDistance 30
  adjustFonts 1
  doubleBuffer 1
  clipping 1
  nCopyAreas 0
  drawTextLimit 0.5
  saveObjects 1
  canvasBackground #050048007800
  defaultForeground #000000000000
  layers 1
  layerName 0 0
  layerName 1 1
  layerName 2 2
  layerName 3 3
  layerName 4 4
  layerName 5 5
  layerName 6 6
  layerName 7 7
  layerName 8 8
  layerName 9 9
  layerName 10 10
  layerName 11 11
  layerName 12 12
  layerName 13 13
  layerName 14 14
  layerName 15 15
  layerName 16 16
  layerName 17 17
  layerName 18 18
  layerName 19 19
  layerName 20 20
  layerName 21 21
  layerName 22 22
  layerName 23 23
  layerName 24 24
  layerName 25 25
  layerName 26 26
  layerName 27 27
  layerName 28 28
  layerName 29 29
  layerName 30 30
  layerName 31 31
  gend
  
  N 0
  P 0 0
  T -1
  R 0 0
  0
      0 4 1 0
      Name #WVP
      0 1 1
  !
  27e
  054878
  -1-1-1
  0
  0
  0
  0 0
  dynamics
  script
  //***GblSymDetails***
  ;DTLS; GSA_TEXT = "CIUXX"
  //***ApplReplace***
  //GEMTool = 1
  // = ASPECTLINK
  end script
  end dynamics
      0 0 1920 1080 0 0
  N 2
  P 34.7792 181.549
  T 2 21071 1 0 0
  0 0
  R 0 0
  0
      0 0 3 0
      Name STAT5495
      0 1 1
  !
  27e
  a5a5a5
  a5a5a5
  0
  0
  0
  2 0
      0 0 0
      0 0 0 0 1 
      4
      0 12.7627
      11.5724 0
      192.874 0.255264
      185.159 12.3798
  N 4
  P 221.604 181.887
  T 2 21071 1 0 0
  0 0
  R 0 0
  0
      0 0 5 0
      Name STAT5496
      0 1 1
  !
  27e
  7c7c7c
  7c7c7c
  0
  0
  0
  2 0
  dynamics
  script
  func ip_FillColor() {
  return FILLCOLOR;
  }
  func ip_LineColor() {
  return LINECOLOR;
  }
  func ip_TEXT() {
  return TEXT;
  }
  func BackColor() {
  return RGB(124,124,124);
  
  }
  
  
  func ForeColor() {
  return RGB(124,124,124);
  
  }
  
  
  
  
  
  
  
  
  
  
  
  
  // when ...
  object.background = BackColor();
  object.foreground = ForeColor();
  end script
  end dynamics
      0 0 0
      0 0 0 0 1 
      4
      0 11.6149
      6.04944 0
      6.04944 54.445
      0 72.5933
  N 6
  P 81.7124 181.888
  T 2 21071 1 0 0
  0 0
  R 0 0
  0
      0 0 7 0
      Name STAT5497
      0 1 1
  !
  27e
  616161
  616161
  0
  0
  0
  2 0
  dynamics
  script
  func ip_FillColor() {
  return FILLCOLOR;
  }
  func ip_LineColor() {
  return LINECOLOR;
  }
  func ip_TEXT() {
  return TEXT;
  }
  func BackColor() {
  return RGB(97,97,97);
  
  }
  
  
  func ForeColor() {
  return RGB(97,97,97);
  
  }
  
  
  
  
  
  
  
  
  
  
  
  
  // when ...
  object.background = BackColor();
  object.foreground = ForeColor();
  end script
  end dynamics
      0 1 0
      0 0 0 0 1 
      72
      93.8536 5.86588
  </code></pre>