Hello,
I have a spreadsheet that includes a few columns with a lot of text. To autofit the rows without taking those into account, I wrote the following code, which copies the first 11 columns of each row to row 2001, autofits it, then takes the row height and applies it to the original row. Rather roundabout, I know, but I couldn't come up with something more efficient.
However, it's resizing all of the rows each time rather than saving each one's height individually, so they all end up the same height as the last row. Does anyone have an idea as to how I can change the code to make that happen? Thanks!
I have a spreadsheet that includes a few columns with a lot of text. To autofit the rows without taking those into account, I wrote the following code, which copies the first 11 columns of each row to row 2001, autofits it, then takes the row height and applies it to the original row. Rather roundabout, I know, but I couldn't come up with something more efficient.
However, it's resizing all of the rows each time rather than saving each one's height individually, so they all end up the same height as the last row. Does anyone have an idea as to how I can change the code to make that happen? Thanks!
Code:
Dim N as long
Dim I as long
N = Sheets("New FNA").Cells(Rows.Count, "B").End(xlUp).Row
For i = 4 To N
Range(Cells(i, 1), Cells(i, 11)).Copy Destination:=Range("A2001")
Range("A2001").EntireRow.AutoFit
Range("i:i").RowHeight = Range("A2001").RowHeight
Next i
Range("A2001").EntireRow.Clear