If something other than a Range is selected (i.e. a Shape, Chart, etc.), it won't work


Option Explicit


Sub test()


    If TypeOf Selection Is Range Then
        Selection.Cells(1, 1).FormulaR1C1 = "foo"
        Debug.Print "done"
    
    Else
        Debug.Print "not done"
    End If
    
End Sub