JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
Following code errors on highlighted line with Error 13, type mismatch:
Read various online forums for answers (e.g. declare arr without brackets, size limitations) but nothing suggested removes this error and the data is contained in A25:B35 in Sheet1 only
The below code runs fine (in same workbook), without error, so can't tell if it's syntax related:
Any help on removing the error in the top macro?
TIA, Jack
Following code errors on highlighted line with Error 13, type mismatch:
Rich (BB code):
Sub Test1()
Dim x As Long
Dim arr() As Variant
With Sheets("Sheet1")
x = .Cells(.Rows.Count, 1).End(xlUp).Row
arr = .Cells(25, 1).Resize(x - 24, 2).Value
End With
For x = LBound(arr, 1) To UBound(arr, 1)
Select Case arr(x, 2)
Case Is = 1, 2
Case Else: arr(x, 1) = Null
End Select
Next x
With Sheets("Sheet2")
With .Cells(.Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(arr, 1))
.Value = Application.Index(arr, 0, 1)
.SpecialCells(xlCellTypeBlanks).Delete xlUp
End With
End With
Erase arr
End Sub
The below code runs fine (in same workbook), without error, so can't tell if it's syntax related:
Rich (BB code):
Sub Test()
Dim arr() As Variant
arr = Cells(1, 1).Resize(3, 2).Value
Cells(1, 4).Resize(UBound(arr, 1)).Value = Application.Index(arr, 0, 1)
Cells(1, 5).Resize(UBound(arr, 1)).Value = Application.Index(arr, 0, 2)
Erase arr
End Sub
TIA, Jack
Last edited: