Hi!
My sheet have a text box named "TextBox 2" which is placed in the Range("B356:Z375"). The sheet contains a macro to auto fit the textbox within the same Range("A356:A375") irrespective of the height of the textbox, means, if the textbox is resized due to entry of texts, the rows adjust itself to fit with the height of the textbox. The minimum height of the textbox is fixed as 171.
(Please see the attachment below)
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
Else
Range("A356:A375").RowHeight = ActiveSheet.Shapes("TextBox 2").Height / 20
End If
End If
End Sub
Problem:
1. The macro above is running on selection of any cell on the sheet, which, I think, will create unnecessary burden on the system. It should run only after selection of the textbox.
2. Rows are not adjusted exactly as the height of textbox, i.e., text box height is moving a little bit inside or outside of the Range("A356:A375") in bottom, when the height is changed after entering text in the textbox.
Solution of Problem No. 2
One solution, I think, is to readjust the height of the textbox to align it with the Range("A356:A375") or between the row (356:375).
With Thanks!
Anshu
P.S.
I've noticed a strange thing. The UNDO and REDO option is not working due to this Macro.I don't understand what the hell is going on!
Bookmarks