Temeraire24
New Member
- Joined
- Jul 13, 2020
- Messages
- 10
- Office Version
- 365
- Platform
- Windows
I just registered here at Mr. Excel, so if I am posting my question incorrectly please advise.
The following section of code works perfectly as long as the range has more than 1 row, however I get a "error 13; Type mismatch" if the range in my array only has 1 row.
How do I correct this so that if the range only has 1 row it does not error?
Dim MyArray() As Variant
Dim ptclassrow As Long
ptclassrow = Sheets("Instructions").Cells(Rows.Count, ptclasscolumn).End(xlUp).Row
MyArray = Sheets("Instructions").Range(Cells(2, ptclasscolumn), Cells(ptclassrow, ptclasscolumn)).Value2
The following section of code works perfectly as long as the range has more than 1 row, however I get a "error 13; Type mismatch" if the range in my array only has 1 row.
How do I correct this so that if the range only has 1 row it does not error?
Dim MyArray() As Variant
Dim ptclassrow As Long
ptclassrow = Sheets("Instructions").Cells(Rows.Count, ptclasscolumn).End(xlUp).Row
MyArray = Sheets("Instructions").Range(Cells(2, ptclasscolumn), Cells(ptclassrow, ptclasscolumn)).Value2