Results 1 to 7 of 7

single cell for data entry

Threaded View

  1. #1
    Registered User
    Join Date
    01-07-2008
    Posts
    42

    single cell for data entry

    This is a follow up question to a topic I had posted a few months ago. JBeaucaire and Leith, your help was tremendous on this and the resulting script has worked flawlessly. Here is a link to the original thread.

    http://www.excelforum.com/excel-prog...ata-entry.html

    Here is the script as it stands now with no modifications at all.

    Option Explicit
    
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Cell As Range
    Dim N As Double
    
    Worksheets("sheet1").Protect "1234", UserInterfaceOnly:=True, DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowSorting:=True, AllowFiltering:=True
      
        If Not Intersect(Target, Range("$S$8:$S$307")) Is Nothing And Target.Cells.Count = 1 Then
        N = Abs(Target)
           If N > 60 Then
              MsgBox "Number too high"
              Target.Select
              GoTo ExitOut
            End If
    
        Application.EnableEvents = False
    
           Set Cell = Cells(Target.Row, 19 + N)
             If Target.Value < 0 Then
                Cell = ""
                Target.ClearContents
                Target.Select
             Else
                Cell = N
                Target.ClearContents
                Target.Select
             End If
        End If
    
    ExitOut:
        Application.EnableEvents = True
    End Sub
    Currently column (S) is my data entry cell and the immediate following cells starting with column (T) are my "data collection" cells that react to column (T) input.

    I have had to add two columns directly after column (S) for other purposes and one of them (column U) contains a formula . I tweaked the code and was able to get it working again after I added the two columns but I experienced something strange. If I press the delete key in my data entry cell it wipes my formulas out of column U.

    What is the "correct" way to tweak the code so that column (T) and (U) are unaffected or ignored and column (V) being my first "data collection" column.

    With the changes that I made I was able to get it to work but I soon realized the problem with an "accidental" press of the delete key or a cut command has the same affect of wiping out my new formulas. I just need to try and prevent accidents from occuring.

    J.B. or Leith I was hoping you had some insight on this.

    BTW... I have noticed one small thing, if the data entered is not a number...letter for instance I get a run time error 13 (type mismatch) which is not even a big deal and I can live with it as it really doesn't affect the use of the sheet... usually just press end and resume data input.

    Thanks
    Barry C
    Last edited by imatomic; 10-30-2009 at 09:54 AM. Reason: credit to Leith on same project

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1