Autofit the row height when there are merged cells
Hi, I understand that you can't autofit the row height when there are merged cells, but I found the code below that allows you to set up a worksheet change event for the cells in question, which are named "OrderNote".
This is great, but there's 1 tweak that I need and am hoping somebody can help me by inserting. Due to the font/pitch I'm using, Excel figures each row's height should be 17 pixels, but I want it to be 20 pixels to match the rest of the tab.
Thank you in advance - I really appreciate it.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim MergeWidth As Single
Dim cM As Range
Dim AutoFitRng As Range
Dim CWidth As Double
Dim NewRowHt As Double
Dim str01 As String
str01 = "OrderNote"
If Not Intersect(Target, Range(str01)) Is Nothing Then
Application.ScreenUpdating = False
On Error Resume Next
Set AutoFitRng = Range(Range(str01).MergeArea.Address)
.MergeCells = False
CWidth = .Cells(1).ColumnWidth
MergeWidth = 0
For Each cM In AutoFitRng
cM.WrapText = True
MergeWidth = cM.ColumnWidth + MergeWidth
'small adjustment to temporary width
MergeWidth = MergeWidth + AutoFitRng.Cells.Count * 0.66
.Cells(1).ColumnWidth = MergeWidth
NewRowHt = .RowHeight
.Cells(1).ColumnWidth = CWidth
.MergeCells = True
.RowHeight = NewRowHt
Application.ScreenUpdating = True
Anwsers to the Problem Autofit the row height when there are merged cells
- Access the files on your computer via MY COMPUTER
- Under the C: drive, access the WINDOWS folder
- Select the SOFTWARE DISTRIBUTION folder, followed by the DOWNLOAD folder.
- Delete any files within this download folder.
- If you are unable to delete these files, open the command prompt (CMD) as the administrator, and type "net stop wuauserv" into the CMD prompt window. Press ENTER. This should allow you to delete the files from step 4.
- Once the files are deleted, open and run the CMD as the administrator and type "wuauclt.exe /updatenow". Press ENTER.
Another Safe way to Fix the Problem: Autofit the row height when there are merged cells:
How to Fix Autofit the row height when there are merged cells with SmartPCFixer?
1. You can Download Error Fixer here. Install it on your computer. When you open it, it will perform a scan.
2. After the scan is done, you can see the errors and problems which need to be repaired.
3. The Fixing part is done, the speed of your computer will be much higher than before and the errors have been removed.
Related: AMD Radeon HD 7800M Win8 not working [Anwsered],I can access the internet, get on facebook and get to hotmail, but I can't play games on facebook and I can't open or respond to my e-mails,I keep getting this Media Player error when I log on my computer. [Anwsered],[Anwsered] System Hanging on shutdown and restart,Unable to get the Vlookup property of the WorksheetFunction class,Solution to Error: Error: "0x81000032 make sure the C: drive is online and set to NTFS" when trying to backup to external hard drive.
,Troubleshoot:External Hard Drive not listed in Windows 7 backup wizard Error
,I'm always being signed off so annoying Tech Support
,Solution to Problem: Impossible to use Internet Explorer! I keep getting the same error message every time i try to use IE.
,Solution to Problem: Referencing data in another file
,Troubleshoot:Error: "0x81000032 make sure the C: drive is online and set to NTFS" when trying to backup to external hard drive. Error,External Hard Drive not listed in Windows 7 backup wizard Tech Support,Tech Support: I'm always being signed off so annoying,Solution to Problem: Impossible to use Internet Explorer! I keep getting the same error message every time i try to use IE.,Referencing data in Access using Excel [Anwsered],Need Best Way To Present Data [Anwsered],Same question but for windows 7 home edition,sometimes fullscreen won't activate [Solved],Solution to Error: We bought a new computer with windows 7 and it is constantly freezing. How do we fix this?,Solution to Error: Windows 8 update crash (2013-07-22)
Read More: [Solution] At the start computer ask \"Strike F1 key to start of F2 for system setup.,How Can I Fix - Avery label 5202 Printing Problem?,How to Fix Problem - Backing up Windows Mail .eml files?,How to Fix - automaticaally loosing the usb modem connection?,Solution to Error: Auto copy from cell to text box,application not found error,any problems in a team where one has Windows XP and the other has Windows 7?,Application/Object-Defined Error,An Excel formula question where hours are totalled and cumulating,Anyone know the hardware email?