PDA

View Full Version : [SOLVED:] Run-time error '13': type mismatch VBA code



Johnatha
03-02-2016, 11:55 AM
Hi everyone,

I currently have some code that is throwing me an error "Run-time error 13: type mismatch" when I try and run it with my data. Currently, the code runs fine when my data is all text.
However, I am getting this error when I include numbers and punctuation in the data.
The error pops up at line ".Range("A1").Resize(UBound(tblArr, 2)).Value = Application.Transpose(Application.Index(tblArr, 1, 0))".

Any thoughts as to what this means or how I can get around it?


Sub test()

Dim tblArr
Dim i As Long

tblArr = Worksheets("Sheet1").Cells(1).CurrentRegion.Value

For i = 2 To UBound(tblArr)
With Worksheets.Add(After:=Worksheets(Worksheets.Count))
.Range("A1").Resize(UBound(tblArr, 2)).Value = Application.Transpose(Application.Index(tblArr, 1, 0))
.Range("B1").Resize(UBound(tblArr, 2)).Value = Application.Transpose(Application.Index(tblArr, i, 0))
End With
Next i

End Sub

Thanks!

Johnatha
03-04-2016, 07:01 AM
Found my error! It was a problem with my data, not the code :crying: