ActiveSheet.Name not working for some users

Assamita

Board Regular
Joined
Sep 23, 2011
Messages
131
Hi everyone,
I have a report that updates data when the dates are changed either in field C2 (from) or field F2 (to). It goes like this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TValue As String, TAddress As String, Tsource As String

If Target.Address = "$C$2" Or Target.Address = "$F$2" Then
    TAddress = Target.Address
    TValue = Target
    Tsource = ActiveSheet.Name
    Call Date_Change(TValue, TAddress, Tsource)
End If

End Sub
This works well in Excel 2010, but it gives an "Object variable or With block variable not set" from 2013 onwards.
The file has a lot of macros as it's a complex reporting file with several capabilities, and the message is displayed when the user clicks on the enable content button.

Debugging, it leads you to the ActiveSheet.Name, and a msgbox ActiveSheet.Name returns the same error message above, so it's like excel it's not identifying the current sheet.

Any ideas of what could I try?

Thank you
 

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.
Very strange :confused:

If the active sheet is the same sheet as the code belongs to then you can use
Code:
Tsource = Me.Name

or
Code:
Tsource = Target.Parent.Name
 
Last edited:
Upvote 0
Thank you. I think that fixed the issue. I've got a new one, which is weird because I didn't have it before and it's in a complete different part of the code, but I'll deal with that later.
 
Upvote 0
Hi excel gurus. Sorry to resurrect this post, but I identified why this was happening and I wanted to ask you if there's a way to work around. The above error doesn't depend on the Office version. It's happening when the user needs to click the "Enable Editing" button when opening the file from an email:
6DxdWwy.png


However, if the user has the following disabled in Excel, the error is not happening:
3J4e0QQ.png


I guess not, but is there any other way to workaround this issue? something I could put in the code or saving the file in a different way?

Thank you
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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