Hi everyone

Excel 2000 Win7

I am using code below to enter data onto a sheet.  The sheet works well in
entering data, but when you go back to an entry above and delete the current
data and put in the correct data, on the delete key it deletes all data
entered and user has to start over again.

How to stop all data entered being deleted ?:

Thanks

Charlie


******************************

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Establishes tab order for data entry. Hit Enter or Tab keys to jump to the
next cell.

Dim TabOrder As Variant, X As Variant
Dim addr As String
Dim rg As Range, targ As Range
If TabOrderFlag = True Then Exit Sub

TabOrder = Array("h8", "h9", "h10", "h11", "h13", "l11", "l12", "h17",
"k17", "h18", "k18", "k21", "k22", "n26", "n27", "n31", _
"k37", "e82", "f82", "h82", "j82", "e83", "f83", "h83", "j83", "e84", "f84",
"h84", "j84", "e85", "f85", "h85", _
"j85", "e86", "f86", "h86", "j86", "e87", "f87", "h87", "j87", "e88", "f88",
"h88", "j88", "e89", "f89", _
"h89", "j89")

'List your cell addresses in desired tab order here
For Each X In TabOrder
If rg Is Nothing Then
Set rg = Range(X)
Else
Set rg = Union(rg, Range(X))
End If
Next

Set targ = Intersect(rg, Target)
rg.Select
If targ Is Nothing Then
addr = Target.Cells(1, 1).Address(ColumnAbsolute:=False, RowAbsolute:=False)
X = Application.Match(addr, TabOrder, 0)
If IsError(X) Then Range(TabOrder(LBound(TabOrder))).Activate
Else
targ.Activate
End If

End Sub

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to