View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Unspecified Automation Error


On Wed, 24 Jun 2009 16:47:33 -0500, "Don Guillett"
wrote:

I installed these functions in a regular module and entered on the sheet
=revzip(78731) and got Austin
I didn't get any other hits for that zip and didn't get TX


You probably overlooked the comment at the beginning of the routine that the
function returns a 2D array of city-state pairs.

If I go to the formula bar, and select <F9, I see:

{"AUSTIN","CAMP MABRY";"TX","TX"}

So to pull out each city-state pair using this function, you need to use the
INDEX function.

For example,

=INDEX(RevZip($A$1),ROWS($1:1),COLUMNS($A:A))

filled to the right 1 cell and down 1 cell (with 78731 in A1), returns:

AUSTIN CAMP MABRY
TX TX

in four separate cells.

This function is much more efficiently used in a Sub that would populate the
worksheet. In a Sub, you can make a single call to the UDF and then output the
resultant array appropriately.

On the other hand, if you have this formula in four worksheet cells, then there
are four calls to IE, and that will take a considerable amount of time.

--ron