Originally Posted by
Kenneth Hobs
You will find if you review my posts that I most always test my code. Howsoever, I have to make some basic assumptions and leave it to the user to code for scenarios that cause errors.
Obviously, it would error if you change your criterion. The error may be telling you that Column "B" has no data. So, Change "B" to "J" and on sheet1 put some data in column "J" before trying.
Code like this makes some assumptions. e.g.
1. Data is in column "J".
2. The macro is ran from the workbook with this code.
3. Sheet1 exists.
[vba]Sub Ken()
Dim a() As Variant
a() = WorksheetFunction.Transpose(Worksheets("Sheet1").Range("J13", Worksheets("Sheet1").Range("J" & Rows.Count).End(xlUp)))
MsgBox Join(a(), vbLf)
End Sub [/vba]
If you post example workbooks for us to help you with, many assumptions can be made correctly. Half the work in solving a problem is defining it properly. Solutions will very much depend on things like data starting in J13 versus B1 for example.