Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Create New Workbook on Hyperlink

Is there a way using a hyperlink I can click on the hyperlink which will
create a new workbook, copy data from the current workbook to the new one and
then go to the new workbook.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Create New Workbook on Hyperlink

Put a hyperlink in the workbook to some place in the document. Say we put it
in B9. Insert the following worksheet event macro:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Parent.Address < "$B$9" Then
Exit Sub
End If
Application.ScreenUpdating = False
Dim wb1 As Workbook
Dim sh As Worksheet
Set wb1 = ActiveWorkbook
Workbooks.Add
Set wb2 = ActiveWorkbook
For Each sh In wb1.Sheets
sh.Copy Befo=wb2.Sheets(1)
Next
Application.ScreenUpdating = True
End Sub

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200904


"James" wrote:

Is there a way using a hyperlink I can click on the hyperlink which will
create a new workbook, copy data from the current workbook to the new one and
then go to the new workbook.
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Create New Workbook on Hyperlink

This worked great, thanks!

"Gary''s Student" wrote:

Put a hyperlink in the workbook to some place in the document. Say we put it
in B9. Insert the following worksheet event macro:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Parent.Address < "$B$9" Then
Exit Sub
End If
Application.ScreenUpdating = False
Dim wb1 As Workbook
Dim sh As Worksheet
Set wb1 = ActiveWorkbook
Workbooks.Add
Set wb2 = ActiveWorkbook
For Each sh In wb1.Sheets
sh.Copy Befo=wb2.Sheets(1)
Next
Application.ScreenUpdating = True
End Sub

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200904


"James" wrote:

Is there a way using a hyperlink I can click on the hyperlink which will
create a new workbook, copy data from the current workbook to the new one and
then go to the new workbook.
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Create New Workbook on Hyperlink

You should consider using a button in the future.
--
Gary''s Student - gsnu200904


"James" wrote:

This worked great, thanks!

"Gary''s Student" wrote:

Put a hyperlink in the workbook to some place in the document. Say we put it
in B9. Insert the following worksheet event macro:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Parent.Address < "$B$9" Then
Exit Sub
End If
Application.ScreenUpdating = False
Dim wb1 As Workbook
Dim sh As Worksheet
Set wb1 = ActiveWorkbook
Workbooks.Add
Set wb2 = ActiveWorkbook
For Each sh In wb1.Sheets
sh.Copy Befo=wb2.Sheets(1)
Next
Application.ScreenUpdating = True
End Sub

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200904


"James" wrote:

Is there a way using a hyperlink I can click on the hyperlink which will
create a new workbook, copy data from the current workbook to the new one and
then go to the new workbook.
Thanks

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
Create Hyperlink to cell in another Workbook saved in Doc Manageme DeniseS Excel Discussion (Misc queries) 0 January 3rd 07 04:33 PM
how can I create a save file hyperlink or macro in a workbook? Jon Peltier Excel Programming 0 December 29th 06 06:33 PM
How do I create a hyperlink to a cell with the hyperlink function S. Bevins Excel Worksheet Functions 2 July 20th 06 08:06 PM
Create Hyperlink maperalia Excel Programming 2 April 10th 06 01:15 AM
Intra-workbook hyperlink: macro/function to return to hyperlink ce marika1981 Excel Discussion (Misc queries) 3 May 6th 05 05:47 AM


All times are GMT +1. The time now is 06:56 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"