Take a look at these Macros and see if they can help you write your macro:
For more information, see the wiki Searching the Forum for Answers section.