Code in ThisWorkbook not working on new sheets.

Delorean14

New Member
Joined
Apr 4, 2012
Messages
33
Hello, and I'd like to say thank you in advance for helping, if you can. Ok, so the code that I have placed in "ThisWorkbook" of "Microsoft Excel Objects" in the visual basic editor. Here is the code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then
Target.Offset(0, 1).Select
ElseIf Target.Column = 3 Then
Target.Offset(0, 1).Select
ElseIf Target.Column = 4 Then
Target.Offset(2, -2).Select

End If
End Sub

Now, the workbook contains a hidden template sheet that is copied and pasted into a new sheet when a button is pressed to create a new sheet. After which, the code above does not work. I've tried putting the code in the template's object, and it then works in the template, but not in the sheets created from it. Is there a way to copy the code to the new sheet's object, or make ThisWorkbook actually work? This is VERY frustrating! Thanks!
 
Sorry, you can't post files here.
You can either post a sample of the data using the HTML Maker in my tag or upload the file to a hosting site and post the link to the site back here....but a lot of posters will not or cannot download from these sites....I can't !!

AND
looking at the code you have posted, it doesn't put anything in E4
Code:
Sheets("Picking_Sheet").Range("E2") = Dte
Sheets("Picking_Sheet").Range("E3") = Answer
NewName = Sheets("Picking_Sheet").Range("E4")

Maybe it should be
Code:
Sheets("Picking_Sheet").Range("E2") = Dte
Sheets("Picking_Sheet").Range("E3") = Answer
NewName = Sheets("Picking_Sheet").Range("E2").value & " " & Range("E3").Value
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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