Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop through range, Autofit height
This is a sub I made to loop through a range and autofit row height of each
row: Sub AutoHeight() Dim c As Range For Each c In Sheet1.Range("AutoFit") Rows.AutoFit Next c End Sub The macro just keeps running and running. What;'s wrong with my sub? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop through range, Autofit height
What are your parameters for the range named "AutoFit", which, by the way,
is a bad practice to use reserved words for names and variables. "John" wrote in message ... This is a sub I made to loop through a range and autofit row height of each row: Sub AutoHeight() Dim c As Range For Each c In Sheet1.Range("AutoFit") Rows.AutoFit Next c End Sub The macro just keeps running and running. What;'s wrong with my sub? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop through range, Autofit height
Firstly, make sure you always have Option Explicit at the top of every
module and form. You will see why when you try to run the code you posted with that done. Then try code like this: Sub AutoHeight() Dim r As Long With Sheets("Sheet1").Range("AutoFit") For r = 1 To .Rows.Count .Rows(r).AutoFit Next r End With End Sub RBS "John" wrote in message ... This is a sub I made to loop through a range and autofit row height of each row: Sub AutoHeight() Dim c As Range For Each c In Sheet1.Range("AutoFit") Rows.AutoFit Next c End Sub The macro just keeps running and running. What;'s wrong with my sub? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop through range, Autofit height
This might work better if the named range is defined.
Sub AutoHeight() Sheets("Sheet1".Range("AutoFit").Rows.AutoFit End Sub "John" wrote in message ... This is a sub I made to loop through a range and autofit row height of each row: Sub AutoHeight() Dim c As Range For Each c In Sheet1.Range("AutoFit") Rows.AutoFit Next c End Sub The macro just keeps running and running. What;'s wrong with my sub? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop through range, Autofit height
Sheets("Sheet1".Range("AutoFit").Rows.AutoFit
Ah, yes, of course no need for the loop as I posted. RBS "JLGWhiz" wrote in message ... This might work better if the named range is defined. Sub AutoHeight() Sheets("Sheet1".Range("AutoFit").Rows.AutoFit End Sub "John" wrote in message ... This is a sub I made to loop through a range and autofit row height of each row: Sub AutoHeight() Dim c As Range For Each c In Sheet1.Range("AutoFit") Rows.AutoFit Next c End Sub The macro just keeps running and running. What;'s wrong with my sub? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop through range, Autofit height
works even better with the parentheses in place: Sub AutoHeight() Sheets("Sheet1").Range("AutoFit").Rows.AutoFit End Sub "RB Smissaert" wrote in message ... Sheets("Sheet1".Range("AutoFit").Rows.AutoFit Ah, yes, of course no need for the loop as I posted. RBS "JLGWhiz" wrote in message ... This might work better if the named range is defined. Sub AutoHeight() Sheets("Sheet1".Range("AutoFit").Rows.AutoFit End Sub "John" wrote in message ... This is a sub I made to loop through a range and autofit row height of each row: Sub AutoHeight() Dim c As Range For Each c In Sheet1.Range("AutoFit") Rows.AutoFit Next c End Sub The macro just keeps running and running. What;'s wrong with my sub? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop through range, Autofit height
Ah, yes, infinite better!
RBS "JLGWhiz" wrote in message ... works even better with the parentheses in place: Sub AutoHeight() Sheets("Sheet1").Range("AutoFit").Rows.AutoFit End Sub "RB Smissaert" wrote in message ... Sheets("Sheet1".Range("AutoFit").Rows.AutoFit Ah, yes, of course no need for the loop as I posted. RBS "JLGWhiz" wrote in message ... This might work better if the named range is defined. Sub AutoHeight() Sheets("Sheet1".Range("AutoFit").Rows.AutoFit End Sub "John" wrote in message ... This is a sub I made to loop through a range and autofit row height of each row: Sub AutoHeight() Dim c As Range For Each c In Sheet1.Range("AutoFit") Rows.AutoFit Next c End Sub The macro just keeps running and running. What;'s wrong with my sub? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Set a minimum row height a the same time with autofit row height | New Users to Excel | |||
Autofit Row Height | Excel Discussion (Misc queries) | |||
Autofit row height | Excel Discussion (Misc queries) | |||
Need a row to autofit height after it's value changes | Excel Discussion (Misc queries) | |||
Autofit row height | Excel Programming |