ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can rows / columns be resized based on the value of cells? (https://www.excelbanter.com/excel-programming/433658-can-rows-columns-resized-based-value-cells.html)

Michael Lanier

Can rows / columns be resized based on the value of cells?
 
I would like columns and rows to adjust according to the values I
enter cells. For example, if A1=12, then I want column C to be
widened to a width of 12. If A2=15, then row 3 should heighten to a
height of 15. Is this possible? Thanks for your help.

Michael

p45cal[_116_]

Can rows / columns be resized based on the value of cells?
 

Put your two values in A1 and A2 then run this
macro:Sub Blah()
Columns("C:C").ColumnWidth = Range("A1").Value
Rows("3:3").RowHeight = Range("A2").Value
End Sub
or put the following in the sheet's code
module:Private Sub Worksheet_Change(ByVal Target As
Range)
If Target.Address = Range("A1").Address Then
Columns("C:C").ColumnWidth = Range("A1").Value
End If
If Target.Address = Range("A2").Address Then
Rows("3:3").RowHeight = Range("A2").Value
End If
End Sub
and watch the column width and row height change as you
enter different values in the two cells.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=135028


Michael Lanier

Can rows / columns be resized based on the value of cells?
 
Thanks. I'll be giving it a try shortly.

Michael


All times are GMT +1. The time now is 06:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com