KVT Holland
New Member
- Joined
- May 10, 2017
- Messages
- 21
Hi,
I found a peace of code written bij Joe Was in:
https://www.mrexcel.com/forum/excel-questions/9165-entire-row-delete.html
I modified it to work on a command button. But it removes every other row Lets say row 11 till 18 are empty/< 1 then it removes 11, 13, 15, 17. I've tried it with a ' in front of the N = N + 1, but that didn't change anything.
Kind regards,
Koen.
I found a peace of code written bij Joe Was in:
https://www.mrexcel.com/forum/excel-questions/9165-entire-row-delete.html
I modified it to work on a command button. But it removes every other row Lets say row 11 till 18 are empty/< 1 then it removes 11, 13, 15, 17. I've tried it with a ' in front of the N = N + 1, but that didn't change anything.
Code:
Private Sub CommandButton2_Click()
ActiveSheet.Unprotect Password:="PW"
Worksheets("Calculatie").Select
Range("A11:A30").Select
n = 1
n = n + 1
For Each r In Worksheets("Calculatie").UsedRange.Rows
n = r.Row
If Worksheets("Calculatie").Cells(n, 1) < 1 Then
Worksheets("Calculatie").Cells(n, 1).Select
Selection.EntireRow.Delete
End If
Next r
Application.ScreenUpdating = True
Range("A11").Select
ActiveSheet.Protect Password:="PW"
End Sub
Kind regards,
Koen.