Phelony2
08-01-2013, 02:49 AM
Hi Guys
Had to create a new profile, so I'm not as green as I look!
I'm trying to create a custom function to turn .close .save etc into a variable that can be applied to the thisworkbook function.
I suspect the problem I'm having is largely due to not knowing what to call the function in terms of string, object, action etc.
What I've got is as follows (I know that DoAsTold shouldn't be a string, but I'm lost for what it should be!)
Public Function DoAsTold() As String
Dim dothis As String
Select Case Sheets("sheet1").Range("C1").Value
Case "A"
'close
dothis = Sheets("sheet1").Range("B2").Text
Case "B"
'save
dothis = Sheets("sheet1").Range("B3").Text
End Select
DoAsTold = dothis
'MsgBox DoAsTold
End Function
Which in turn should then interact with:
Sub doaction()
ThisWorkbook.DoAsTold
End Sub
Can anyone shed any light on where I'm going wrong, or even just tell me what the function after "thisworkbook" is actually called so I can go Google a solution?
Thanks
Phel
Had to create a new profile, so I'm not as green as I look!
I'm trying to create a custom function to turn .close .save etc into a variable that can be applied to the thisworkbook function.
I suspect the problem I'm having is largely due to not knowing what to call the function in terms of string, object, action etc.
What I've got is as follows (I know that DoAsTold shouldn't be a string, but I'm lost for what it should be!)
Public Function DoAsTold() As String
Dim dothis As String
Select Case Sheets("sheet1").Range("C1").Value
Case "A"
'close
dothis = Sheets("sheet1").Range("B2").Text
Case "B"
'save
dothis = Sheets("sheet1").Range("B3").Text
End Select
DoAsTold = dothis
'MsgBox DoAsTold
End Function
Which in turn should then interact with:
Sub doaction()
ThisWorkbook.DoAsTold
End Sub
Can anyone shed any light on where I'm going wrong, or even just tell me what the function after "thisworkbook" is actually called so I can go Google a solution?
Thanks
Phel