Excel VBA Type Mismatch Error Passing Range To Array - Stack Overflow
Excel VBA Type Mismatch Error Passing Range To Array - Stack Overflow
Home
Excel VBA Type Mismatch Error passing range to array Ask Question
PUBLIC Asked 6 years, 7 months ago Active 6 years, 7 months ago Viewed 16k times
Questions
I'm trying to retrieve the values of an array of cells in a worksheet (stored as an array rather than
Tags The Overflow Blog
simple cells), but for some reason keep getting a Run-Time Error 13 Type Mismatch. I've read
Users 2 posts about similar issues, but many of those seem to have to do with either the array being of the Introducing The Key
wrong type (ie NOT Variant type), or being of static size.
FIND A JOB Podcast 326: What does being a “nerd”
even mean these days?
Jobs Here is the relevant line where the error occurs in debugging:
3 This is a good read and in fact answers your question. – L42 Aug 11 '14 at 6:26 0 Type Mismatch assigning worksheets to
array
Add a comment
0 Type-Mismatch on For Each Range
Anti Arzela-Ascoli
1 I should also admit that I don't actually know why using the parenthesis will cause an error in this situation,
Is "mens semita tua" the correct translation for
especially since Dim Arr() As Variant: Arr = Range("A1:C5") is acceptable but Dim "mind your path"?
Arr() As Variant: Arr = ThisWorkbook.Sheets(1).Range("A1:C5") isn't. I only know
from encountering it myself. – stobin Aug 11 '14 at 2:12 Recommendations on how to buy clipless bike
shoes
1 Hi, you might be interested in the link I posted in the OP's question. That in fact answers his and your
Temperature sensor read out is influenced by LED
question. – L42 Aug 11 '14 at 6:37
Red Herring Redherring
Thanks for the quick responses! For some reason declaring the variable without parentheses didn't work,
but declaring a range variable and setting SizeSelection equal to that did the trick. @L42 thanks for the Getting buy-in for clean code and refactoring
link to the article, I hadn't come across that one in my searching. To be honest I don't fully understand the
reasoning behind it, but at least now I know the workaround if I encounter this again! Thanks so much for Red Black Trees for Limit Order Book
saving my sanity! – MikeG Aug 12 '14 at 3:31
Can I glue the X axis to the Y axis?
@MikeG It's pretty simple. You just need to explicitly instruct excel what you're passing to an array of
variant variable especially if what you're passing could be one of two things. – L42 Aug 12 '14 at 4:26 more hot questions
Your Answer
Links Images Styling/Headers Lists Blockquotes Code HTML Tables Advanced help
Not the answer you're looking for? Browse other questions tagged arrays excel vba type-mismatch
STACK OVERFLOW PRODUCTS COMPANY STACK EXCHANGE Blog Facebook Twitter LinkedIn Instagram
NETWORK
Questions Teams About
Technology
Jobs Talent Press
Life / Arts
Developer Jobs Directory Advertising Work Here
Culture / Recreation
Salary Calculator Enterprise Legal
Science
Help Privacy Policy
Other
Mobile Terms of Service
Disable Responsiveness Contact Us
Cookie Settings
site design / logo © 2021 Stack Exchange Inc; user contributions
Cookie Policy licensed under cc by-sa. rev 2021.4.1.38970