Same code, two different worksheets, one Run-time error '91

Certified

Board Regular
Joined
Jan 24, 2012
Messages
189
I copied what looked like an easy macro form a website. The macro works perfectly with the worksheet I downloaded, but when try to utilize the macro in my worksheet I receive a Run-time error.

code from website:
Code:
Private Sub Worksheet_Activate()
For i = 1 To 10
    Sheets("Names").Cells(i, 1).Comment.Delete
    Sheets("Names").Cells(i, 1).AddComment
    Sheets("Names").Cells(i, 1).Comment.Text Text:=Sheets("Ages").Cells(i, 1).Text
    Sheets("Names").Cells(i, 1).Comment.Shape.TextFrame.AutoSize = True
Next
End Sub

Code I am using with my workbook and receiving "Run-time error 91"

Code:
Private Sub Worksheet_Activate()

For i = 2 To 10
    Sheets("SI Mapping (accountant)").Cells(i, 23).Comment.Delete
    Sheets("SI Mapping (accountant)").Cells(i, 23).AddComment
    Sheets("SI Mapping (accountant)").Cells(i, 23).Comment.Text Text:=Sheets("Current.comments").Cells(i, 5).Text
    Sheets("SI Mapping (accountant)").Cells(i, 23).Comment.Shape.TextFrame.AutoSize = True
Next
End Sub

What am I doing wrong?
 

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