Thread: =If(Macro)
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default =If(Macro)

if you make SortJ a function

Sub SortJ()

End Sub

to

Function SortJ()


SortJ = "SomeValue"
End Function


So as the last line or at least some line, you assign a value for SortJ to
return to the cell for display.

If you have any selecting in the recorded macro, you will need to eliminate
that.

You will not be able to change any cells in any way - only return a value to
SortJ which will be displayed by your function. Just like a built in
function.

--
Regards,
Tom Ogilvy


"AntnyMI" wrote in message
oups.com...
Is there a way to incorporate a macro into an If/Then statement?
For example, in Cell A1: =If(B1="Johnson",SortJ,"")
<<where "SortJ" is the name of the recorded macro