G
geofferrington
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(xlConstants).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
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(xlConstants).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