# Stange .RowHeight results

#### tschop

##### New Member
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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

#### Special-K99

##### Well-known Member
What's the whole code?

#### tschop

##### New Member
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``````

#### tschop

##### New Member
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.

#### Special-K99

##### Well-known Member
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.