#1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2
Default Macro Help Needed

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?'

I can send you the spreadsheet complete with macro if you need me to.

Love Claire

  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 5,600
Default Macro Help Needed

Hi Claire,

Not sure I follow, and wonder why you want to copy a sheet and delete all(?)
its contents rather than simply adding a new sheet.

I suspect the following is not quite what you want, but run it a few times
for ideas.

Sub test()
Dim i As Long
Dim sName As String
Dim rng As Range

Set rng = Worksheets("Sheet1").Range("R1")

sName = "Sheet2 (#)"

i = 1
On Error Resume Next
Do
Set ws = Nothing
i = i + 1
Set ws = ActiveWorkbook.Worksheets(Replace$(sName, "#", i))
Loop Until ws Is Nothing
On Error GoTo 0

Worksheets("Sheet2").Copy befo=Worksheets(2)

sName = "'" & Replace$(sName, "#", i) & "'!A1"

rng.Parent.Hyperlinks.Add Anchor:=rng.Offset(i - 1), _
Address:="", SubAddress:=sName
rng.Parent.Activate
End Sub

You'll find for this type of question you will get more or quicker responses
if you post in the ".excel.programming" group, unless of course it relates
to charts

Love Peter T

"Claireyscott" wrote in message
...
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?'

I can send you the spreadsheet complete with macro if you need me to.

Love Claire



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 :( [email protected] Excel Worksheet Functions 2 April 7th 08 03:06 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro help needed CLR Excel Discussion (Misc queries) 0 November 30th 06 03:23 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 10:37 PM.

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"