Sure thing. Generally, you'll want to first format the cells you are putting the formula/refer to as text, so that you can write the formula. Then, you can do something like:
I'm note sure I totally understand your requirements but you may want to have a look at a Technique I have described here : http://chandoo.org/wp/2011/06/23/automating-repetitive-tasks/