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

mdd16

New Member
Joined
Jan 11, 2011
Messages
26
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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

jsb1921

Board Regular
Joined
Aug 14, 2020
Messages
70
Office Version
  1. 2007
Platform
  1. Windows
  2. Web
VBA Code:
For Each cell In Sheets("360 LM Prnt").Range("C30:C46")
    cell.EntireRow.RowHeight = Cells(cell.Row, "B").Value
Next cell
 

jsb1921

Board Regular
Joined
Aug 14, 2020
Messages
70
Office Version
  1. 2007
Platform
  1. Windows
  2. Web
If it helped you. pl mark it as a solution for future readers of the thread.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,309
Messages
5,641,448
Members
417,209
Latest member
Agbarker

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
Top