Solved

How to delete data in cells in last entry

Posted on 2014-07-23
2
153 Views
Last Modified: 2014-07-23
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
0
Comment
Question by:cssc1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 40215238
This will delete the last entries on Main Menu.
Sub DeleteEntryToDB()
    Application.ScreenUpdating = False
    Sheets("Main Menu").Range("B" & Rows.Count).End(xlUp).Resize(,10).ClearContents
    Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Closing Comment

by:cssc1
ID: 40215328
THanks this works GREAT!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question