troubleshoot ActiveSheet.Name

G

Guest

Guest
Hello, can anyone out there see a reason the following code would fail? I had the EXACT code in another macro that worked fine. I have gone through this macro line by line and all works well except the second (and probably 2nd to last) lines refering to shtOriginal. What happens is that when I run the macro it will debug with the 2nd line 'shtOriginal' phrase highlighted and the error message 'variable not defined'. The purpose of the second and 2nd to last line is so that after the info is copied and pasted to the '5th worksheet' I want it to then return to WHICHEVER of the worksheets (1-4) the user was last on.
Sub HELP()
'
' CutPaste Macro
' Macro recorded 26/02/2002 by
'

'
Application.ScreenUpdating = False
shtOriginal = ActiveSheet.Name
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Sheets("My Class").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
With Selection.Font
.Name = "Arial"
.Size = 8
End With
Sheets(shtOriginal).Select
ActiveCell.Offset(1, 1).Activate
Application.ScreenUpdating = True
End Sub

Any ideas? Many thanks if so!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,214,784
Messages
6,121,540
Members
449,038
Latest member
Guest1337

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