Atmospheric aerosols are significant sources of uncertainty in air mass factor (AMF) calculations for trace gas retrievals using ultraviolet measurements from space. Current trace gas retrievals typically do not consider aerosols explicitly as cloud products partially account for aerosol effects. Here, we propose a new measurement-based approach to correct for aerosols explicitly in the AMF calculation, apply it to Ozone Monitoring Instrument (OMI) formaldehyde (HCHO) retrievals and quantify the aerosol-induced HCHO vertical column density difference for three aerosol types (smoke, dust, and sulfate) during 2006-2007. We use OMI aerosol retrievals for aerosol optical properties and vertical profiles to construct lookup tables of scattering weights as functions of geometry, surface pressure, surface albedo, and aerosol information. The average difference between the National Aeronautics and Space Administration operational OMI HCHO product (not considering aerosols) and the results obtained in this study on a global scale are 27%, 6%, and -0.3% for smoke, dust, and sulfate aerosols, respectively. The region with the largest aerosol effects is East China, where the explicit smoke aerosol correction enhances mean HCHO vertical column densities by 35%, with corrections to individual observations sometimes larger than 100%. The quantified aerosol effects are applicable under clear-sky conditions. This study highlights the need to implement aerosol corrections in the AMF calculation for HCHO retrievals. This is particularly relevant in regions with high levels of pollution where aerosols interfere the most with formaldehyde satellite observations.