Duplicate excelsheet by clicking a specific cell in excel. Possible?

iscon

New Member
Joined
Mar 6, 2019
Messages
2
Hi everyone,

First I must say that this forum is awesome. Everybody wants to help!

So to my question. Is it possible to create a macro that makes it possible to duplicate the activated sheet by clicking a cell (Something like a "hyperlink"). Is this possible to do? I would be grateful if someone took a look at it.

/V
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
58,493
Office Version
  1. 365
Platform
  1. Windows
How about
Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
   If Target.Address(0, 0) = "A1" Then
      Cancel = True
      Sh.Copy , Sheets(Sh.Index)
   End If
End Sub
This needs to go in the ThisWorkbook module & will copy the active sheet if you double-click A1
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,652
Office Version
  1. 2013
Platform
  1. Windows
Try this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Double click on Range("A1") and this script will make a duplicate of the sheet

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  3/7/2019  10:46:43 AM  EST
Cancel = True
Dim ans As String
ans = ActiveSheet.Name
If Not Intersect(Target, Range("A1")) Is Nothing Then
Sheets(ans).Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "New " & ActiveSheet.Index
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,133,427
Messages
5,658,733
Members
418,467
Latest member
sc356448

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top