Senin, 27 Juni 2011

Re: [ExcelVBA] VBA Tab Order - Deleting Entry

 

Try using Select rather than Activate. It's just possible it might make a
difference.

Failing that, you probably need to determine the row and column of the cell
you want to activate, then unselect the big select, and then activate the
required cell.

Regards, Dave S

----- Original Message -----
From: <railroads@slingshot.co.nz>
To: <ExcelVBA@yahoogroups.com>
Sent: Monday, June 27, 2011 6:21 PM
Subject: [ExcelVBA] VBA Tab Order - Deleting Entry

> Hi
>
> When using the code below, if you make an error in a entry and hit the
> delete button, all cells get deleted. Somewhat frustrating. The code
> works well, except for the delting all cells when hitting the delete
> button. Is there a code to add to stop this happening ?
>
> Thanks
>
> Charlie Harris
>
> ****
>
> 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
>
>
>
>
> ------------------------------------
>
> ----------------------------------
> Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
> here: http://www.mousetrax.com/techtrax to enter the ezine, then search
> the ARCHIVES for EXCEL VBA.
>
> ----------------------------------
> Visit our ExcelVBA group home page for more info and support files:
> http://groups.yahoo.com/group/ExcelVBA
>
> ----------------------------------
> More free tutorials and resources available at:
> http://www.mousetrax.com
>
> ----------------------------------Yahoo! Groups Links
>
>
>
>

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar