Yes. As long as the property is being used for business or investment purposes, a 1031 loan can be used for both commercial and residential investment properties, including multifamily units, rentals, and apartment buildings.