Configuring Double Click
Hi Geoff,
Your code could be simplified to:
'===============
Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
On Error GoTo err_handler
With Target
If Not Intersect(Target, Range("F2:F8")) Is Nothing Then
If Not IsEmpty(.Value) Then
ThisWorkbook.FollowHyperlink ThisWorkbook.Path _
& "\" & .Value
End If
End If
If .Row 11 Then
Cancel = True
.Offset(1).EntireRow.Insert
.EntireRow.Copy .Offset(1).EntireRow
On Error Resume Next 'In case no constants found!
.Offset(1).EntireRow.SpecialCells(xlConstants). _
ClearContents
On Error GoTo 0
End If
End With
Exit Sub
err_handler:
MsgBox "An error has been made" & vbCrLf _
& "File name not recognised.", _
vbExclamation, "Error Notice"
End Sub
'<<===============
With reference to:
If Target.Address row 11 Then 'Could I have the correct expression
for "row 11" please
Cancel = True
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
Target.Offset(1).EntireRow.SpecialCells(xlConstant s).ClearContents
End If
I did not immediately understand the descibed scenario to which this code
snippet relates. I have therefore simply revised the syntax and added error
handling to allow for the possible absence of constant values.
---
Regards,
Norman
wrote in message
oups.com...
Hi there.
I am using 2002 and am having a small problem with the required syntax
of a "Target.Address" statement. The code that needs to be changed is
indicated at the bottom end of the following code.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
On Error GoTo err_handler
If Target.Address = "$F$2" Then
ActiveWorkbook.FollowHyperlink ThisWorkbook.Path & "\" &
Range("F2").Value
Cancel = True
End If
If Target.Address = "$F$3" Then
ActiveWorkbook.FollowHyperlink ThisWorkbook.Path & "\" &
Range("F3").Value
Cancel = True
End If
If Target.Address = "$F$4" Then
ActiveWorkbook.FollowHyperlink ThisWorkbook.Path & "\" &
Range("F4").Value
Cancel = True
End If
If Target.Address = "$F$5" Then
ActiveWorkbook.FollowHyperlink ThisWorkbook.Path & "\" &
Range("F5").Value
Cancel = True
End If
If Target.Address = "$F$6" Then
ActiveWorkbook.FollowHyperlink ThisWorkbook.Path & "\" &
Range("F6").Value
Cancel = True
End If
If Target.Address = "$F$7" Then
ActiveWorkbook.FollowHyperlink ThisWorkbook.Path & "\" &
Range("F7").Value
Cancel = True
End If
If Target.Address = "$F$8" Then
ActiveWorkbook.FollowHyperlink ThisWorkbook.Path & "\" &
Range("F8").Value
Cancel = True
End If
'-------------------------------------------------------------
If Target.Address row 11 Then 'Could I have the correct expression
for "row 11" please
Cancel = True
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
Target.Offset(1).EntireRow.SpecialCells(xlConstant s).ClearContents
End If
'-------------------------------------------------------------
Exit Sub
err_handler:
MsgBox "An error has been made" & vbCrLf & "File name not recognised.",
_
vbExclamation, "Error Notice"
End Sub
Hopefully this code will indicate what I am trying to achieve here, so
any input on how I can make this code more efficient would be greatly
appreciated.
Also. that code between the dashed lines works well at inserting a new
line, but I now require it to just move all the data in columns B,C,D
and E down one line and insert a space in each new cell. There are no
formulae in these areas. I wish to do it this way because I do not want
the eventual user to be troubled with removing the error tabs created
by a formula in column A.
BTW. for anyone who is interested... Inserting the spaces into empty
cells is the technique I use to avoid coding repetitive "VLOOKUPs" in
an "IF" statement in order to stop that "0" being placed in there.
Any assistance is greatly appreciated
Geoff
|