Running Macros in added sheets within same workbook

Harry69

New Member
Joined
Dec 16, 2021
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi

I have a spreadsheet with various formulae across the columns. I have a macro which inserts a new row with format & formulae below a double-click.

Each worksheet represents a financial year & when I set it up, I covered 3 years. I now need to add a year and I have copied the data into a new sheet but the macro isn't working. I can't see any way to trigger it for the new sheet as all the sheets are listed on the VBA Project along with the Module.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True 'Eliminate Edit status due to doubleclick
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy Target.Offset(1).EntireRow
On Error Resume Next
Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi & welcome to MrExcel.
Did you copy the code into the sheet module for the new sheet you have created?
 
Upvote 0
Thanks for reply.

I right clicked on the sheet within VBA and Insert Module and pasted the module there before saving, closing & opening, but no action. Is that what you mean?
 
Upvote 0
That is the wrong place in needs to go in the sheet module, not a standard module.
In the project explorer double click the sheet it needs to work on & paste the code into the window that opens up.
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

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
Back
Top