I have a numerous worksheets that contain data which is graphed several different ways.

After my users enter the data, when they Deactivate the worksheet, I have a the following code for each of the worksheets.


Private Sub Worksheet_Deactivate()
    CleanData "1EWA"
End Sub
This calls my custom function


Function CleanData(wsName As String)
    Dim varLastRow As Integer
    Dim varLastColumn As Integer
    
    'Determine the last row that has data entry
    varLastRow = Worksheets(wsName).Range("A1048576").End(xlUp).Row
    
    'Determine the last column that has data entry
    varLastColumn = Worksheets(wsName).Range("A3").End(xlToRight).Column
        
    For Each cl In Worksheets(wsName).Range("A3", Cells(varLastRow, varLastColumn)).Cells
        If Not IsError(cl.Value) And cl.Value = "" Then
            cl.Value = "=NA()"
        End If
    Next
End Function
First Question: Instead of using the specific worksheet name, how do I obtain the name of the sheet that was just deactivated, using Activesheet gives the name of the worksheet that was newly selected.

Second Question: The "For Each" statement does not work...what do I have wrong?

Lastly: When in VBA, on the properties dialog, I see (name) as the first entry, and then Name further down in the dialog. What's the different between the two? Should/can I use the (name) value, so that in case the user changes the tab name, the code will still work?


Thank you.