#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 788
Default Add/Delect Macro

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Add/Delect Macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"