ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a way that I can control a row's height with programming? (or cell contents) (https://www.excelbanter.com/excel-programming/300670-there-way-i-can-control-rows-height-programming-cell-contents.html)

lseyer

Is there a way that I can control a row's height with programming? (or cell contents)
 
I'm trying to control the height of a row determined by the contents o
a cell...

I can't seem to find a function or command that is available to me t
allow this.

Alternatively, is there a way that I can 'hide' or 'unhide' a row base
on a cell's contents?

Best to you!

Larry Seye

--
Message posted from http://www.ExcelForum.com


Anders Silven

Is there a way that I can control a row's height with programming? (or cell contents)
 
Larry,

Some ideas,

To change row height:
'*****
Sub test45()
With ActiveSheet.Rows(3)
If .Cells(1) = "Q2" Then
.RowHeight = 25
Else
.RowHeight = 12.75
End If
End With
End Sub
'*****

To hide the row:
'*****
Sub test45B()
With ActiveSheet.Rows(3)
If .Cells(1) = "Q2" Then
.Hidden = True
End If
End With
End Sub
'*****

HTH
Anders Silven

"lseyer " skrev i meddelandet
...
I'm trying to control the height of a row determined by the contents of
a cell...

I can't seem to find a function or command that is available to me to
allow this.

Alternatively, is there a way that I can 'hide' or 'unhide' a row based
on a cell's contents?

Best to you!

Larry Seyer


---
Message posted from http://www.ExcelForum.com/



lseyer[_2_]

Is there a way that I can control a row's height with programming? (or cell contents)
 
Thanks for your help!

Here is the code that worked for me...

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

For rwindex = 1 To 26
If Worksheets("Items").Cells(rwindex, 1).Value = "0" Then
Worksheets("Items").Rows(rwindex).Hidden = True
Else
Worksheets("Items").Rows(rwindex).Hidden = False
End If
Next rwindex

End Su

--
Message posted from http://www.ExcelForum.com


Anders Silven

Is there a way that I can control a row's height with programming? (or cell contents)
 
And to save some typing,

'*****
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Dim rwindex
With Worksheets("Items")
For rwindex = 1 To 26
If .Cells(rwindex, 1).Value = "0" Then
.Rows(rwindex).Hidden = True
Else
.Rows(rwindex).Hidden = False
End If
Next rwindex
End With
End Sub
'*****

Regards,
Anders Silven

"lseyer " skrev i meddelandet
...
Thanks for your help!

Here is the code that worked for me...

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

For rwindex = 1 To 26
If Worksheets("Items").Cells(rwindex, 1).Value = "0" Then
Worksheets("Items").Rows(rwindex).Hidden = True
Else
Worksheets("Items").Rows(rwindex).Hidden = False
End If
Next rwindex

End Sub


---
Message posted from http://www.ExcelForum.com/




All times are GMT +1. The time now is 01:14 PM.

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