Macro to Autofit Rows - Based on Column Entry

Jim-in-I

Board Regular
Joined
Sep 10, 2002
Messages
180
I have finally exhausted my searches on this topic and hope that someone with a better head for VBA might be able to lead me there.

I am attempting to create a macro that will Autofit only the rows which contain "TRUE" in Column B. (The "TRUE" entry in column B is derived from a formula that is checking for maximum words in a range of cells on that row). This sounded like a simple task, but it has stumped me.

Any pointers would be greatly appreciated.

Jim
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
Would this work for you?

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> test()
<SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range, i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>

<SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> [B65536].End(xlUp).Row
    <SPAN style="color:#00007F">Set</SPAN> c = Cells(i, 2)
    <SPAN style="color:#00007F">If</SPAN> c.Value = "TRUE" <SPAN style="color:#00007F">Then</SPAN> c.EntireRow.AutoFit
<SPAN style="color:#00007F">Next</SPAN> i
    
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 

Jim-in-I

Board Regular
Joined
Sep 10, 2002
Messages
180
Kristy,

That worked perfectly! I just could not figure out the exact syntax, but your solution resolved that very issue. Thanks for taking your time to help and instruct me.

Jim
 

Forum statistics

Threads
1,147,846
Messages
5,743,515
Members
423,801
Latest member
paulj4177

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top