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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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>
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,049
Latest member
THMarana

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
Back
Top