MassiveJim
New Member
- Joined
- Aug 18, 2018
- Messages
- 5
I have been using the following code for some time now, and of all the code that I use this has always been problematic.
I often get a type 13 mismatch error and my macro fails to run properly.
The issue for me is I am not super competent with VBA, I get by using the excel record function and googling the gaps where I need code that the recorder can't handle.
I don't understand this bit of code or how it exactly works to be able to modify/change it, or better yet find a different way of handling the function I need.
The code is looking at the value in cell L2 in sheet1 and finding it in another spreadsheet, then copying a range of data from sheet 1 (all arranged in 1 column, but not an entire column) and transposing it to the row in sheet 2 where it found the value it looked for.
95% of the time it works, but I have just found out that it will fail if any of the cells contain over 255 characters (which they occasionally might), it also sometimes fails without the 255 character limit for some reason. is there a better way of executing this function ?
I often get a type 13 mismatch error and my macro fails to run properly.
Code:
Dim rngFound As Range: Set rngFound = Columns("A").Find(WSO.Range("L2").Value) If rngFound Is Nothing Then
MsgBox "HW ID""" & WSO.Range("L2").Value & """ was not found in the DB. ", , "Data not found"
GoTo ErrHandler
Else
Cells(rngFound.Row, "B").Resize(1, WorksheetFunction.CountA(WSO.Range("L2:L21")) - 1).Value = _
WorksheetFunction.Transpose(WSO.Range("L3:L21", WSO.Cells(Rows.Count, "L").End(xlUp)).Value)
End If
The issue for me is I am not super competent with VBA, I get by using the excel record function and googling the gaps where I need code that the recorder can't handle.
I don't understand this bit of code or how it exactly works to be able to modify/change it, or better yet find a different way of handling the function I need.
The code is looking at the value in cell L2 in sheet1 and finding it in another spreadsheet, then copying a range of data from sheet 1 (all arranged in 1 column, but not an entire column) and transposing it to the row in sheet 2 where it found the value it looked for.
95% of the time it works, but I have just found out that it will fail if any of the cells contain over 255 characters (which they occasionally might), it also sometimes fails without the 255 character limit for some reason. is there a better way of executing this function ?