Hi there. I am an occasional VBA programmer and have run into a type mismatch problem that has me stumped. I am using the ancient 2007 edition of Excel (not my choice) and the following code in my macro works:
(This uses so-called Hungarian notation so that you may see the data type of the variables and objects used).
However, cell A1 contains a header, and I do not want to add that to my array, so I made the following change:
i.e. I changed the starting cell of the range reference from A1 to A2. Now the VB runtime is telling me that there is a type mismatch error in the varCohort assignment in the second line and the code will no longer run. I do not understand what the difference should be. (varCohort is of type variant, and is to hold a dynamic array).
I did not want to paste the entire code of my macro into this post because it is fairly lengthy. Please tell me if more information is required to answer this question, and thank you for your time.
Code:
Set rngCohort = wsScrap.Range("A1:A" & lngScrapLast)
varCohort = rngCohort.Value
(This uses so-called Hungarian notation so that you may see the data type of the variables and objects used).
However, cell A1 contains a header, and I do not want to add that to my array, so I made the following change:
Code:
Set rngCohort = wsScrap.Range("A2:A" & lngScrapLast)
varCohort = rngCohort.Value
i.e. I changed the starting cell of the range reference from A1 to A2. Now the VB runtime is telling me that there is a type mismatch error in the varCohort assignment in the second line and the code will no longer run. I do not understand what the difference should be. (varCohort is of type variant, and is to hold a dynamic array).
I did not want to paste the entire code of my macro into this post because it is fairly lengthy. Please tell me if more information is required to answer this question, and thank you for your time.