View Single Post
  #1   Report Post  
clvrbas clvrbas is offline
Junior Member
 
Posts: 12
Default Delete unused rows / clear unused rows

Hi Experts!

I am in the process of making a profile book for a work function. I have employees from various levels that will be attending the function. What i am trying to do is have a profile book that they will fill, then have a command button that they can click to delete all fields that do not apply to them. I have some merged cells and I have been struggling with clearing them. I have been able to partially get a delete function to work, however it is deleted almost everything!!! Below is the code I have been working with. Please advise.

I also am struggling on how to make it so the button is visible however will not print once this goes into production.

Private Sub CommandButton2_Click()
Dim nr As Long, i As Long
Application.ScreenUpdating = False
Application.EnableEvents = False 'usually want to disable, but sometimes not
nr = Range("g5:g14").SpecialCells(xlLastCell).Row
For i = nr To 1 Step -1
With Range("g5:g14").Cells(i)
If .Value = "" Then
.EntireRow.Delete
End If
End With
Next i
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub