Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-21-2025, 04:50 AM
p45cal's Avatar
p45cal p45cal is offline Excel 2003 - autofitting rows based only on selected column Windows 10 Excel 2003 - autofitting rows based only on selected column Office 2021
Expert
 
Join Date: Apr 2014
Posts: 962
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default


try:
Code:
Sub AutofitRowsToColumnO()
Dim ws As Worksheet
Dim rng As Range
Dim cell As Range
Dim minHeight As Double
    
Set ws = ActiveSheet
' Work on used range in Column O
Set rng = ws.Range("O1:O" & ws.Cells(ws.Rows.Count, "O").End(xlUp).Row)
    
Application.ScreenUpdating = False
minHeight = 1E+99
For Each cell In rng
  cell.Rows.AutoFit
  minHeight = Application.Min(minHeight, cell.RowHeight)
Next cell
rng.EntireRow.RowHeight = minHeight
Application.ScreenUpdating = True
End Sub
This will get you closer but won't work properly because Excel's cell.Rows.AutoFit does not work on a single cell like cell.Columns.AutoFit does!
Reply With Quote
Reply

Tags
excel 2003



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Header and footer in word document based upon company selected in excel. starmumbai Mail Merge 4 02-02-2022 10:12 PM
Excel 2003 - autofitting rows based only on selected column Delete blank table rows in merged document and split document in docx and pdf based on excel rows Alex1s85 Word VBA 5 05-22-2021 12:05 PM
Excel 2003 - autofitting rows based only on selected column Set Range based on selected rows. 14spar15 Excel Programming 8 11-19-2018 08:08 AM
Excel 2003 - autofitting rows based only on selected column Insert values from multiple rows based on value in one column pachmarhi Excel 3 07-18-2014 09:57 PM
Excel 2003 - autofitting rows based only on selected column Referencing rows of a table at a bookmarked location based on the value of a column jpb103 Word VBA 11 05-22-2014 08:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft