ed.ayers315
Board Regular
- Joined
- Dec 14, 2009
- Messages
- 166
Hello forum,
I read many posts on this subject.
I put together the following code and have a worksheet in my Dropbox. C:\Users\EDWARD P AYERS\Dropbox file name is TEXT MERGE RESIZE
This code is not perfect; it does adjust with different column widths and font sizes. It uses formulas on Sheet1 to help get the sizing close. It also has a method with a formula to account for Char (10) additions in the text of the cell.
What I am looking for is help to make this work in the following manner:
1) have a variable range of rows 2:300
2) have variable columns from B:J
3) look at each row, select the value for the largest merged cell and run the code below for that intersecting cell.
4) loop through from row 2 to 300
5) should only work on visible rows.
I read many posts on this subject.
I put together the following code and have a worksheet in my Dropbox. C:\Users\EDWARD P AYERS\Dropbox file name is TEXT MERGE RESIZE
This code is not perfect; it does adjust with different column widths and font sizes. It uses formulas on Sheet1 to help get the sizing close. It also has a method with a formula to account for Char (10) additions in the text of the cell.
What I am looking for is help to make this work in the following manner:
1) have a variable range of rows 2:300
2) have variable columns from B:J
3) look at each row, select the value for the largest merged cell and run the code below for that intersecting cell.
4) loop through from row 2 to 300
5) should only work on visible rows.
Code:
Sub row_resize()
Dim CurrentFont As Long
Dim CurrentLen As Long
Dim Char10 As Long
Dim RowHeight As Long
Dim CombinedRowHeight As Integer
Dim columnwide As Integer
columnwide = Columns("C:C").ColumnWidth
RowHeight = Range("h5").Value
CurrentLen = Len(Range("c5"))
CurrentFont = Range("c5").Font.Size
Range("$j$5").Value = CurrentFont
Range("$l$5").Value = columnwide
CombinedRowHeight = (RowHeight * (CurrentFont / 9))
Rows("5:5").Select
Selection.RowHeight = CombinedRowHeight
End Sub