programming cell autofit doesn't work?

P

Philippe

I have developed a small data entry system to make my bosses' secretary life
easier. The proble is when she print out what are the current jobs for the
IT dprt, (2 of us), I cannot get excel to autofit cells in specifi rows.

The rows for some reason hide the last line of the content of the cells
whose content need to be readable.

Here I select an entire row and apply Autofit to each cell on that row, but
it doesn't work
(curRow is avariable that holds the Current Row No)

Range("E" & curRow & ":" & "G" & curRow).Select
With Selection
.VerticalAlignment = xlTop
.HorizontalAlignment = xlLeft
.WrapText = True
.Rows.AutoFit
End With

Any idea would be greatly appreciated.

TIA all

Philippe
 
C

Claud Balls

This worked for me:

Sub autofit()
For curRow = 1 To ActiveSheet.UsedRange.Rows.Count
Range("A" & curRow).EntireRow.Select
With Selection
.VerticalAlignment = xlTop
.HorizontalAlignment = xlLeft
.WrapText = True
.Rows.autofit
End With
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top