I want to be able to create a help sheet using a function call, but Excel vba ignores the sheets.add and sheets.delete methods. Using as stand ins the .activate and .select methods also fails, yet they work ok for VBA subs. Here is my codes for both methods:
Public Function TestBuildHelpSheet(eInput As String) As Double
Stop
Dim ws As Variant
For Each ws In Sheets
If ws.Name = "Help Sheet" Then ws.Activate ' doesn't work
Next
End Function
Sub RemoveHelpSheet()
Stop
'
' This works fine, changing ws.activate to ws.delete also works;
' It deletes the help sheet. Also tried ws.Select, same result
'
Dim ws As Variant
For Each ws In Sheets
If ws.Name = "Help Sheet" Then ws.Activate ' works
Next ws
End Sub
The eInput is just something for the function to receive to get going, and the stops are to allow the switchover to F8 stepping.
Why does this work with Subs, and not with functions? I also tried having the function call the sub, but that didn't work either.