Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to make users not to

Status
Not open for further replies.

bnageshrao

Programmer
Mar 17, 2001
83
US
Is there a way to make users not to use mouse by writing some kind of code in Vba forcing them to enter data in cell by cell rather than using mouse to move around the spread sheet.
 
the only way that I can think of to do this is using the selection_change event for the resepctive worksheet. This solution does not look at mouse activity, and I dont think you can do stuff like that in VBA.

use the selection_change event to test whether the newly selected cell is adjacent to the last selected cell. In this way the user will have to move the selected cell with the keyboard or at least when using the mouse click on a cell next to the one currently selected. am I describing this well enough?

heres some code to try...

'\\***insert this line into a module
public rLastCell as range

'\\***these two procedures should sit inside the worksheet object code
Private Sub Worksheet_Activate()
Set rlastcell = Selection
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If (Target.Row > rlastcell.Row + 1 Or Target.Row < rlastcell.Row - 1) _
Or (Target.Column > rlastcell.Column + 1 Or Target.Column < rlastcell.Column - 1) Then
'\\insert your required action here
rlastcell.Select
Else
Set rlastcell = Target
End If
End Sub


you need the code in the worksheet activate event to initialise rlast cell
of course you can mess with the code to make them go down rows or across columns or whatever...

hope this helps.

Kaah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top