PDA

View Full Version : Solved: Read cell comment text into array varible



snidera
09-26-2006, 01:29 PM
I'm trying the read the text in a comment to an element of a udt array.

UDT ....Summary().discription as string

For j = 1 To UBound(DefectCode())
ReDim Preserve DefectCodeSummary(1 To j)
DefectCodeSummary(j).Discription = Worksheets("Lists").Range(Cells(j + 1, _
6).Address(xlA1)).Comment.Text
Next j

i get an application or object defined error when this runs. it works if i specify a single cell rather than looping through. (cells(2,6) works, but cells(i+1,6) does not, even though they refer to the same cell at the first loop)

mdmackillop
09-26-2006, 05:39 PM
Try

DefectCodeSummary(j) = Worksheets("Lists").Cells(j + 1, 6).Comment.Text

snidera
09-27-2006, 06:53 AM
Try

DefectCodeSummary(j) = Worksheets("Lists").Cells(j + 1, 6).Comment.Text



changed to:
DefectCodeSummary(j).discription = Worksheets("Lists").Cells(j + 1, 6).Comment.Text
because of the udt array (i have string and integer data types i want to keep together)

Stupid me, my j + 1 was making the counter go past the end of the array. For some reason, my control array has a blank at position 1, so on similar things i had used for j =2 to ubound(array()) but on this one i was using 1 to ubound, then adding 1 to get the right data. I missed the error because i was worried that i ddint have the syntax right for the comments.text code

Thanks for your help.:beerchug: