PDA

View Full Version : populating dynamic arrays from a dynamic array



mcotter11
06-20-2014, 11:36 AM
I have 2 worksheets with very large amounts of data in each. I need to do several different compares against both of them. The first I need to do is create a new workbook of all the records on sheet1 not on sheet2, then those on sheet2 not on sheet1. I have read sheet1 into a dynamic array and sheet2 into another seperate dynaic array. I then am reading thru sheet1 array and looking for the instance of a value (ssn) on sheet2. If not found, I would like to put 3 fields from sheet1 array into a new array call NotFoundArray. I am getting a type mismatch when I try to add the second value to the NotFoundArray.

ReDim NotFoundArray(NotFoundRecCnt, 3)
....

NotFoundCnt = NotFoundCnt + 1
NotFoundArray(NotFoundCnt, 1) = TempSSN
NotFoundArray(NotFoundCnt, 2) = TempName 'name
NotFoundArray(NotFoundCnt, 3) = "Not found in sheet2" 'message

I add 1 to NotFoundCnt everytime I have another instance of SSN not found. I get the type mismtach on the 'name line of code.

westconn1
06-20-2014, 02:33 PM
as you do not show the types of your variables, can not give a definitive answer
what type is notfoundcnt?
what type is tempname?
try an explicit type conversion to avoid type mismatch
maybe the array is numeric? therefore can not accept a string