I am using Excel 2003. Occasionally, I have a spreadsheet where I need to solve a value. There are unique provider numbers which take up a single row in the spreadsheet. Each provider number belongs to a geozip, has a number of beds, and a Charge1 value. There is a final column to the right called "Selection" which is unpopulated. This column needs to be populated with a provider number that is not the same provider number in column A. Here is the logic to populate this field: (1) Select a provider number within the same geozip; (2) Select a provider number with the highest number of beds; (3) If criteria (1)(2) yield a value, but the Charge1 is identical, then select another provider number with the next highest number of beds; (4) if there are no geozips that meet the criteria, then go to the next geozip+1, geozip-1, geozip+2, geozip-2, geozip+3, geozip-3, until a suitable value is found.
This macro needs to be written to I can use it on other spreadsheets with the same field structures in columns A-D.
I am attaching a sample file, in which the first 12 rows have been completed.