Where does this code go..In the FormLoad?
It goes after you load the data into the grid (which depends on your program.


Anyway desflynn, your code does the job, but this is slightly faster (as it doesn't change the row/column):
VB Code:
  1. Dim max_width as Long
  2. Dim tmp_width as Long
  3. With Grid
  4.   .Redraw = False
  5.   For y = 0 To .Cols - 1
  6.     max_width = 0
  7.     For x = 0 To .Rows - 1
  8.       tmp_width = TextWidth(.TextMatrix(x,y))
  9.       If tmp_width > max_width Then max_width = tmp_width
  10.     Next x
  11.     .ColWidth(y) = max_width +100 ' 100 or whatever extra
  12.   Next y
  13.   .Redraw = True
  14. End With

And rather than 100 I would recommend using Screen.TwipsPerPixelX * 5, as it will be the same size on all computers (the usual measurement unit - Twips - can vary between computers)