Solved

How to delete data in cells in last entry

Posted on 2014-07-23
2
139 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
2 Comments
 
LVL 33

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now