Autofit

  • Thread starter Thread starter kevin
  • Start date Start date
K

kevin

Earlier I posted a question to this forum concerning
setting a row to Autofit. The answer I got was to use the
following code:

With Worksheets("sheet1").Rows(39)
.RowHeight = .AutoFit
End With

When this executes, the row hight is reduced to 1 pt. Why?

Any help would be appreciated!

Kevin
 
Think you mistaken Kevin. The answer you got was:

Sub CCCC()
With Worksheets("Sheet1").Rows(39)
.AutoFit
End With
End Sub


I don't see any .RowHeight in that answer anywhere.
 
Just to add. If you want to know why you have the problem as you set it up:

From the immediate window:

? activecell.Entirerow.autofit
True

so it autofits the row properly and returns true which you then set to the
row height.

RowHeight is looking for a long so looking at the conversion:

? clng(activecell.Entirerow.autofit)
-1

Not sure why it doesn't just hide the row, but perhaps it discards the
negative sign.
 

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

Back
Top