Execute function at dinamic area

I want to run a function at every block in an area that has to be defined This is to transform small builds into block entities (im using it for an elevator) and i already know how to do everything except i want not to have to hardcore every block, so how can i (maybe specifyng starting x y z and final x y z make it run a function at every coord in this area?
Continue to help post