#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Macro help

Hi Mum,

Hope you are having a good day so far.

This is the message I just posted on t'interweb, can you pass it to whoever
you think might be able to help me!

'Hello,

Can someone help me, I am trying to create a macro in excel that allows me
to create a copy of a worksheet, clear its contents then hyperlink it to a
particular cell.

The problem is that I want it to link a different page to a different cell
every time i.e. create sheet 2(3) and link to R3. create sheet 2(4) link to
cell R4, but I can only make it so that it creates the copy, deletes the
contents and the links cell R2 with Sheet 2(2), at the moment the coding
looks like this:

Sheets("Sheet2").Select
Sheets("Sheet2").Copy Befo=Sheets(2)
Sheets("Sheet1").Select
Range("R2").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'Sheet2 (2)'!A1"

What would I need to add or change to make it do what I want to?'

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro help

Hi,

Put this in a general module. It copies the active sheet and creates a
hyperlink to the copy in column R of sheet 1.

Sub stance()
ActiveSheet.Copy Befo=ActiveSheet
Myname = ActiveSheet.Name
Sheets("Sheet1").Select
Lastrow = Cells(Cells.Rows.Count, "R").End(xlUp).Row
Range("R" & Lastrow).Offset(1, 0).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", _
SubAddress:="'" & Myname & "'!A1"
End Sub

Mike

"Claireyscott" wrote:

Hi Mum,

Hope you are having a good day so far.

This is the message I just posted on t'interweb, can you pass it to whoever
you think might be able to help me!

'Hello,

Can someone help me, I am trying to create a macro in excel that allows me
to create a copy of a worksheet, clear its contents then hyperlink it to a
particular cell.

The problem is that I want it to link a different page to a different cell
every time i.e. create sheet 2(3) and link to R3. create sheet 2(4) link to
cell R4, but I can only make it so that it creates the copy, deletes the
contents and the links cell R2 with Sheet 2(2), at the moment the coding
looks like this:

Sheets("Sheet2").Select
Sheets("Sheet2").Copy Befo=Sheets(2)
Sheets("Sheet1").Select
Range("R2").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'Sheet2 (2)'!A1"

What would I need to add or change to make it do what I want to?'

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
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


All times are GMT +1. The time now is 08:12 PM.

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

About Us

"It's about Microsoft Excel"