Autofit Row Height

Chewyhairball

Active Member
Joined
Nov 30, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
Hi
I have a range of cells Sheet1 C7:C1000 that autofit the row height when the data in those cells is changed.
The data is pulled from another sheet and updates when I type certain criteria into a combobox.

It works great and when more text is pulled through it automatically changes the the row height as I am typing in the combobox.

The VBA i have is a Worksheet_Calculate but i have found that it also tries to run if i am on other sheets and change C7:C1000 on them.

I thought putting the event in the specific sheet would mean it only ran on that sheet but its not the case.

I tried a Worksheet Change but that doesnt give me what i need as it required a <return> and thats not how my sheet runs. I use the combobox and it changes the data in the rows as i type.

Any ideas how I can keep my code but only have it run on the one sheet. Thanks

VBA Code:
Private Sub Worksheet_Calculate()
 Dim Xrg As Range
    Set Xrg = Range("C7:C1000")
    If Not Intersect(Xrg, Range("C7:C1000")) Is Nothing Then
    rowheight
    End If
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
That will only run if that sheet is calculated, but it will run whenever any formulae on the sheet recalculate.
 
Upvote 0
That will only run if that sheet is calculated, but it will run whenever any formulae on the sheet recalculate.
Yes. If I make a change to cells in sheet 2 it tries to run the code and errors. It’s a pain. ?
 
Upvote 0
If the rowheight code is crashing, I'd suggest starting a new thread asking how to prevent that.
 
Upvote 0
If the rowheight code is crashing, I'd suggest starting a new thread asking how to prevent that.
Thanks. It works perfect as long as there are no other sheets being used. Think I’ll just have it as a separate worksheet. I’ve got to many tabs as it is. ? cheers.
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,792
Members
449,048
Latest member
greyangel23

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