Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2012, 02:53 AM
Registered User
 
Join Date: Jul 2012
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Default EXCEL VBA help

Hi,
there is the EXCEL VBA code:
Code:
 Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Column = 5 Then
 EIL_SKAICIUS = 0
 ESAMA_EILUTE = ActiveCell.Row
 EIL_SKAICIUS = Application.CountA(Range("A:A"))
 Sheets("SARASAS").Cells(EIL_SKAICIUS + 1, 2).Value = Sheets("SARASAS").Cells(ESAMA_EILUTE - 1, 5).Value
 Sheets("SARASAS").Cells(EIL_SKAICIUS + 1, 3).Value = Sheets("SARASAS").Cells(ESAMA_EILUTE - 1, 3).Value
 Sheets("SARASAS").Cells(EIL_SKAICIUS + 1, 4).Value = Sheets("SARASAS").Cells(ESAMA_EILUTE - 1, 4).Value
 End If
 End Sub
Now, after when in 5th column write a value, system automaticaly copy 3,4,5 columns values of actual row to new row 2,3,4 columns of end list. I need, what after press DELETE buton, code would be not activ, do nothink, but DELETE key function would be working (delete cell value). How to do it ?

Last edited by kompiuteriumeistras; July 2nd, 2012 at 03:27 AM..
 
Old July 11th, 2012, 05:46 AM
Registered User
 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

does this simple idea help you?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target = Empty Then
        Debug.Print "probably pressed delete"
    Else
        Debug.Print "New value is:"; Target.Value
    End If
End Sub
if yes then you can probably change
Code:
If Target.Column = 5 Then
to
Code:
If Target.Column = 5 and target<>empty Then
it doesn't trap or affect the key-press but deals with the effect

Last edited by Apostolos55; July 11th, 2012 at 05:48 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
#NAME? error running Excel 2003 VBA in Excel 2007 steveburn Excel VBA 0 October 24th, 2009 08:47 AM
Help! Conversion Excel 2003 VBA codes to Excel 2007 sunny76 BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 August 13th, 2009 05:38 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
Excel VBA to SQL & back to VBA edesousa Excel VBA 1 June 1st, 2004 02:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.