ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   programming cell autofit doesn't work? (https://www.excelbanter.com/excel-programming/320758-programming-cell-autofit-doesnt-work.html)

Philippe[_4_]

programming cell autofit doesn't work?
 
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



Claud Balls

programming cell autofit doesn't work?
 
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



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Philippe[_4_]

programming cell autofit doesn't work?
 
Sounds good, I'll give it a try, thanks for your reply.

Philippe
"Claud Balls" wrote in message
...
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



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com