title: Randomly Selecting Cells for Clearing Contents - Excel VBA
body: <p>I currently have rows of merged cells. I need a way to randomly select 50% of these cells to clear the contents of through VBA. </p>
  
  <p>This is what I have so far: </p>
  
  <pre><code>Sub DelFifty()
  Dim rng As Range
  Dim i As Long, x As Long, y As Long
  
  Set rng = Range("B1:M36")
  
  On Error GoTo ErrHandler
  
  Application.Calculation = xlCalculationManual
  Application.ScreenUpdating = False
  
  For i = 1 To Int(rng.Cells.Count * 0.5)
  retry:
      x = WorksheetFunction.RandBetween(1, rng.Rows.Count)
      y = WorksheetFunction.RandBetween(1, rng.Columns.Count)
      If rng.Cells(x, y) &lt;&gt; "" Then
          rng.Cells(x, y).ClearContents
      Else
          GoTo retry
      End If
  Next i
  
  Application.Calculation = xlCalculationAutomatic
  Application.ScreenUpdating = True
  
  ErrHandler:
  Application.Calculation = xlCalculationAutomatic
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>