
Originally Posted by
Anshu
As suggested, I've added the a new line "ActiveSheet.Shapes("TextBox 2").Height = Range("A356:A375").RowHeight * 20" in the macro to set the textbox height to Range("A356:A375").Height.
No you haven't. You're still using .Rowheight.
try:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Overall Observation
If Target.Cells.Count = 1 And IsEmpty(Target) Or Not IsEmpty(Target) Then
If ActiveSheet.Shapes("TextBox 2").Height < 171 Then Let ActiveSheet.Shapes("TextBox 2").Height = 171
Range("A356:A375").RowHeight = ActiveSheet.Shapes("TextBox 2").Height / 20
ActiveSheet.Shapes("TextBox 2").Height = Range("A356:A375").Height '<<<<<<<<<<<this line uses .Height.
End If
End Sub
I'm not sure what you're trying to achieve; if the textbox must always be big enough to fit some text or not. Give us a clue about the order you want things to happen in. Perhaps some narrative of the intention behind the code.
ps those two lines in your code:
Code:
Range("G379").Value = Range("AA368").Height
Range("J379").Value = Rows("368").EntireRow.Height
will always produce the same value; you might get more from:
Code:
Range("G379").Value = Range("AA368").Height
Range("J379").Value = Range("AA368").RowHeight
which will sometimes give different values.
Bookmarks