Link to home
Start Free TrialLog in
Avatar of cssc1
cssc1Flag for United States of America

asked on

How to delete data in cells in last entry

The macro below copies cells C7 to L7 on sheet “Main” and adds this data  the first empty cell on sheet “Main Menu”. The macro below the first macro should delete the last entry but does not work?

I have tried to reverse this process (delete the last entry in cells B to K on sheet “Main Menu” but get errors.





+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub AddEntryToDB()
Application.ScreenUpdating = False
    Sheets("Main").Select
    Range("C7:L7").Select
    Selection.Copy
'
    Sheets("Main Menu").Select

    Range("A1").Select
If Application.WorksheetFunction.CountA("A:A") = 0 Then
 [A1].Select
 Else
 On Error Resume Next
 Columns(2).SpecialCells(xlCellTypeBlanks)(1, 1).Select
 If Err <> 0 Then
 On Error GoTo 0
 [A65536].End(xlUp)(2, 1).Select
 End If
 On Error GoTo 0
 End If
 
 ActiveSheet.Paste
 
    Sheets("Main").Select
    Range("A1").Select
    Application.CutCopyMode = False
    Range("A1").Select

End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Sub DeleteEntryToDB()
Application.ScreenUpdating = False
'
    Sheets("Main Menu").Select

    Range("A1").Select
If Application.WorksheetFunction.CountA("A:A") = 0 Then
 [A1].Select
 Else
 On Error Resume Next
 Columns(2).SpecialCells(xlCellTypeBlanks)(1, 1).Select
 If Err <> 0 Then
 On Error GoTo 0
 [A65536].End(xlUp)(2, 1).Select
 End If
 On Error GoTo 0
 End If
 
 ActiveSheet.Delete
 
    Sheets("Main").Select
    Range("A1").Select
    Application.CutCopyMode = False
    Range("A1").Select

End Sub
P-217---Good-Catch-Application---Version
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cssc1

ASKER

THanks this works GREAT!!