Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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. -- JNW "Chris" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
using a cell value to control a counter inside a macro and displaying macro value | Excel Worksheet Functions | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) |