How to edit row height with conditional formatting?

C

CDAK

I want to edit row height with conditional formatting. I have a query behind
my spreadsheet and there are 3 types of products it returns (X, Y, Z). When
it returns a Z product (product is a column heading), I want the row height
to be much smaller than if it returns a X or Y product. Does anyone know how
this can be done? Thanks.
 
J

JE McGimpsey

not with Conditional Formatting. It could probably be done with a VBA
event macro.
 
C

CDAK

Is this code complicated or is it a simple sub? I've used VB a little bit in
the past but never with Excel so I don't really know where to begin. Can you
give me a little help with the code if you have the time?
 
N

Nick Hodge

You would need to use Worksheet_Change() event code. The code below checks
to see if the change is in column A. If the entry in columnA is a 'Z'. (This
can be changed to anything) then it adjusts the row height to 5. If it is
anything else it remains untouched. Just a starter bit of code. Here's how
you implement it.
(http://www.nickhodge.co.uk/vba/vbaimplement.htm#eventcode)

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Columns("A:A"), Target) Is Nothing Then
With Application
.EnableEvents = False
If UCase(Target.Value) = "Z" Then
Target.RowHeight = 5
End If
.EnableEvents = True
End With
End If
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
[email protected]
 
Top