Error Handling: on Private Sub during copy sheet...

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,782
Office Version
  1. 2016
Platform
  1. Windows
I'm using this code on each sheet to call another macro, but when I try to copy that sheet to a Book1 I get an error.

I've tried to use On Error Resume Next but must not be using it correctly?

Code

Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
SetFontAeral7_RowAutoFit
Application.ScreenUpdating = True
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
It might help to see the other code, that's probably where the problem lies.

It might also help to know what the error is.
 
Upvote 0

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,782
Office Version
  1. 2016
Platform
  1. Windows
this is the Public Code:

Sub SetFontAeral7_RowAutoFit()
ActiveSheet.Unprotect
Application.ScreenUpdating = False
Rows("3:248").Select
Range(Selection, Selection.End(xlDown)).Select
With Selection.Font
.Name = "Arial"
.Size = 7
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With
Selection.Rows.AutoFit
Range("I1").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False
Application.ScreenUpdating = True
End Sub

Private Sub:

Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
SetFontAeral7_RowAutoFit
Application.ScreenUpdating = True
End Sub
 
Upvote 0

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,782
Office Version
  1. 2016
Platform
  1. Windows
forgot

Compile Error

Sub or Function not defined

It is generated on the new book that is created because the sub is not in that book--it's in the book that the sheet was copied from, gut that coode is not needed in the new book...
 
Upvote 0

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,782
Office Version
  1. 2016
Platform
  1. Windows
Straightening up previous post--LAN problems

Compile Error
Sub or Function not defined

It is generated on the new book that is created because the sub is not in that book--it's in the book that the sheet was copied from, but that coode is not needed in the new book...
 
Upvote 0

Forum statistics

Threads
1,186,827
Messages
5,960,027
Members
438,458
Latest member
manojkumarat1999

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