PDA

View Full Version : Move Cells Up after Content is Cleared



Mnet
11-19-2017, 05:53 PM
Hereby my code it is working perfectly ......but how do I move the cleared cells Up? Any suggestions would be highly appreciated!! Thank You!


Private Sub cmbDelete_Click()
Dim msgResponse As String 'confirm delete
Application.ScreenUpdating = False
'get user confirmation
msgResponse = MsgBox("This will delete the selected record. Continue?", _
vbCritical + vbYesNo, "Delete Entry")
Select Case msgResponse 'action dependent on response
Case vbYes

If c Is Nothing Then Set c = Ws.Cells(r, 3)
c.ClearContents 'remove entry by clearing cell content


Set c = Ws.Cells(r, 4)
c.ClearContents 'remove entry by clearing cell content


Set c = Ws.Cells(r, 5)
c.ClearContents 'remove entry by clearing cell content


Set MyData = Ws.Range("C3").CurrentRegion 'database


'restore form settings
With Me
.cmbAmend.Enabled = False 'prevent accidental use
.cmbDelete.Enabled = False 'prevent accidental use

'clear form
ClearControls
End With

Case vbNo
Exit Sub 'cancelled
End Select
Application.ScreenUpdating = True
End Sub

Kenneth Hobs
11-19-2017, 10:42 PM
Rather than clearcontents:
c.Delete xlUp

Mnet
11-20-2017, 01:18 PM
Dear Kenneth, It is working perfectly - thanks a million :clap: