Stange .RowHeight results

tschop

New Member
Joined
Dec 15, 2014
Messages
13
I have a very simple routine that uses:

ThisWorkbook.Worksheets(proposal).Range("B" & a).EntireRow.RowHeight = 17

to set the row height to 17. When the above line of code executes, it sets the row height to 22 instead of 17.

I have two other identical lines of code that should set the row heights to 35 and 46. They instead set the row heights to 46 and 61 respectively.

Can anyone tell me what is going on with this?

Thanks,

Tom
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Code:
For a = TandC + 1 To TandC + b + 7
                If Len(ThisWorkbook.Worksheets(proposal).Range("B" & a).value) > 0 Then
                    lentest1 = Len(ThisWorkbook.Worksheets(proposal).Range("B" & a).value)
                    lentest2 = GetPixelLen.GetStringPixelWidth(ThisWorkbook.Worksheets(proposal).Range("B" & a).value, "Arial", 8)
                    If lentest2 > 0 Then
                        If lentest2 > 634 Then
                            If lentest2 > 1268 Then
                                If lentest2 > 1902 Then
                                    
                                Else
                                    ThisWorkbook.Worksheets(proposal).Range("B" & a).EntireRow.RowHeight = 46
                                End If
                            Else
                                ThisWorkbook.Worksheets(proposal).Range("B" & a).EntireRow.RowHeight = 35
                            End If
                        Else
                            ThisWorkbook.Worksheets(proposal).Range("B" & a).EntireRow.RowHeight = 17
                        End If
                    Else
                        ThisWorkbook.Worksheets(proposal).Range("B" & a).EntireRow.RowHeight = 17
                    End If
                End If
            Next a
 
Upvote 0
For the above code, I am finding the length of a string in pixels to decide how high to set the row height on a collection of merged cells. Based on the number of pixels the string is long, I can determine whether it needs to be 17, 35, or 46 pixels high.

I am doing this because autofit does not work on merged cells.

The function GetStringPixelWidth returns the number of pixels that the string is long.
 
Upvote 0
I'm wondering what would happen if you copied this code and the dependent data to a new workbook and tested it there.
Or possibly just copied the all the data from the dependent sheet to a blank workbook.
Wondering if it's smethign to do with the actual workbook.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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