[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

kirkm

12/16/2006 1:28:00 AM


The following -

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

Dim rng As Range
Dim MyLastCol As Integer
Dim MyLastRow As String
Dim rows, p
Set rng =
Worksheets("Sheet1").Range("A1").SpecialCells(xlCellTypeLastCell)
MyLastRow = rng.Row

rows = "A1:A" & MyLastRow
If Not Intersect(Target, Range(rows)) Is Nothing Then
Cancel = True
p = InputBox("Enter Year", , "1952")
If Len(p) = 4 Then
Select Case p
Case 1952 To 1974
Stop
End Select
End If
End If

End Sub


.... is meant to display an input box.

Sometimes though, it will just select (move to) the first or last cell
in the column. I can't figure out why. Does anyone know?

Thanks - Kirk
2 Answers

Dave Peterson

12/16/2006 1:40:00 AM

0

It's not your code.

It's your mousing ability. If you click on the top edge of a cell, then excel
will treat that like End|UpArrow.

If you click on the bottom edge of a cell, then excel will treat that like
End|DownArrow.

You can change an excel setting so this won't happen, but I don't think you'll
like what you have to turn off:

Tools|Options|Edit tab|Uncheck "Allow cell drag and drop".

I find that it's just better to swear loudly and be more careful!

kirkm wrote:
>
> The following -
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
> As Boolean)
>
> Dim rng As Range
> Dim MyLastCol As Integer
> Dim MyLastRow As String
> Dim rows, p
> Set rng =
> Worksheets("Sheet1").Range("A1").SpecialCells(xlCellTypeLastCell)
> MyLastRow = rng.Row
>
> rows = "A1:A" & MyLastRow
> If Not Intersect(Target, Range(rows)) Is Nothing Then
> Cancel = True
> p = InputBox("Enter Year", , "1952")
> If Len(p) = 4 Then
> Select Case p
> Case 1952 To 1974
> Stop
> End Select
> End If
> End If
>
> End Sub
>
> ... is meant to display an input box.
>
> Sometimes though, it will just select (move to) the first or last cell
> in the column. I can't figure out why. Does anyone know?
>
> Thanks - Kirk

--

Dave Peterson

kirkm

12/16/2006 4:00:00 AM

0

Thanks Dave.
Great to finally know what it is!

Cheers - Kirk