Solved

How to delete data in cells in last entry

Posted on 2014-07-23
2
151 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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.

738 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