Add/Delect Macro

G

Guest

I have set up a add and a delete macro in my WB. I want the user to be able
to delete indivual lines or add a line beneth the add button. I set it up to
use hyperlink text by writing a macro on the sheet code. The Add button is in
column "L" or "12". The delete button is in column "M" or "13". The problem I
am having is it add or delete at the top and not the row inwhich the
hyperlink lies. Below are my current macros. Any help is greatly appreciated.
Thank you :)

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Range.Column = 13 Then Application.Run "'Unit Trend cost out
v1.xls'! del"
If Target.Range.Column = 13 Then Exit Sub
Rows(ActiveCell.Row).Select
Selection.Copy
Selection.Insert Shift:=xlDown
Rows(ActiveCell.Row).Select
Application.CutCopyMode = False

End Sub

Sub del()
ActiveCell.Select
Rows(ActiveCell.Row).Select
Selection.Copy
Rows(ActiveCell.Row).Select
Selection.Delete Shift:=xlDown
Rows(ActiveCell.Row).Select
End Sub
 
G

Guest

This happens because your target for each hyperlink is probably pointing to
A1 or another reference above your links. When the code runs the activecell
gets set as the target range first.

I'm not sure how to fix this since hyperlink targets are not updated when
rows are added and deleted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top