Setting row height for all cells in a range based on value in an offset cell

mdd16

Board Regular
Joined
Jan 11, 2011
Messages
84
Office Version
  1. 365
Platform
  1. Windows
Hello

I am struggling with a code and need help.

I have a range of cells which are merged from col C to col P in each row for about 20 consecutive rows. Each merged cell has long text and I need to adjust row height according to the text length.

I have mentioned the row height in the Col B of the same row. I want to adjust the row height of each cell in C30 to C46 according the col B value of the same row.
I tried to make the macro as follows. But I believe cells object cannot be used with offset command.

Can someone help in setting the code right.

Thanks in advance

Sub Prnt_SpecsRowHt()

For Each cell In Sheets("360 LM Prnt").Range("C30:C46")
.EntireRow.RowHeight = cell.Offset(0, -1).Value
Next cell
End Sub


The text value of C30 to C46, I am bringing with following code

Sheets("360 LM Prnt").Range("SpecL12_360").Value = Sheets("SpecMaster").Range("Spec_UVMS6").Value
Sheets("360 LM Prnt").Range("SpecL12_360").RowHeight = Sheets("SpecMaster").Range("Spec_UVMS6").Offset(0, -1).Value
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
VBA Code:
For Each cell In Sheets("360 LM Prnt").Range("C30:C46")
    cell.EntireRow.RowHeight = Cells(cell.Row, "B").Value
Next cell
 
Upvote 0
If it helped you. pl mark it as a solution for future readers of the thread.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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