title: Close Tab Before Continuing
body: <p>This for each statement is part of an Excel macro which sends personalized messaged via whatsapp using the whatsapp api links. I need to close the tab after each mesage is sent to avoid ending up with chrome with a ton of tabs opened.</p>
  
  <pre><code>For x = 2 To uf
  telwhatsapp = a.Cells(x, "B")
  textwhatsapp = a.Cells(x, "C")
  
  mylinkwhatsapp = "https://api.whatsapp.com/send?phone=" &amp; telwhatsapp &amp; "&amp;text=" &amp; textwhatsapp
  ActiveWorkbook.FollowHyperlink mylinkwhatsapp
  
  Application.Wait (Now + TimeValue("00:00:05"))
  ActiveWindow.Application.SendKeys "{TAB}"
  Application.Wait (Now + TimeValue("00:00:01"))
  ActiveWindow.Application.SendKeys "{TAB}"
  Application.Wait (Now + TimeValue("00:00:05"))
  ActiveWindow.Application.SendKeys "(~)" 'énvia enter para enviar mensaje
  Application.Wait (Now + TimeValue("00:00:18"))
  ActiveWindow.Application.SendKeys "(~)"
  Next x
  Application.ScreenUpdating = True
  Application.DisplayAlerts = True
  End Sub
  </code></pre>
  
  <p>I tried adding this before Next x and it didnt work</p>
  
  <pre><code>ActiveWindow.Application.SendKeys "{%F4}"
  </code></pre>
  
  <p>Also tried this before Next x didnt work neither</p>
  
  <pre><code>ActiveWindow.Application.SendKeys "{^F4}"
  </code></pre>
  
  <p>Any help to close the tab before continuing with the next excel row?</p>