Skip to content

Instantly share code, notes, and snippets.

@guinslym
Created March 8, 2020 02:30
Show Gist options
  • Save guinslym/413b8c7b5f16f4d1685216e794637f75 to your computer and use it in GitHub Desktop.
Save guinslym/413b8c7b5f16f4d1685216e794637f75 to your computer and use it in GitHub Desktop.
Sub count_total_nb_of_rows_and_delete_some_rows()
Dim last_row As Long
Dim total_row_to_remove As Integer
Dim randomNumber As Integer
Dim counter
last_row = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox (last_row)
total_row_to_remove = CInt(last_row * 0.03)
For Row = 2 To total_row_to_remove
randomNumber = Int(2 + Rnd * (total_row_to_remove - 10))
Debug.Print randomNumber
'Rows(randomNumber).EntireRow.Delete
Next
last_row = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox (last_row)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment