Consulting

Results 1 to 3 of 3

Thread: Move Cells Up after Content is Cleared

  1. #1
    VBAX Regular
    Joined
    Nov 2017
    Posts
    7
    Location

    Exclamation Move Cells Up after Content is Cleared

    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

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Rather than clearcontents:
    c.Delete xlUp

  3. #3
    VBAX Regular
    Joined
    Nov 2017
    Posts
    7
    Location
    Dear Kenneth, It is working perfectly - thanks a million

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •