JohnsonFelix
New Member
- Joined
- Jul 22, 2011
- Messages
- 15
Hi Team,
I have long text in one of the cell, Instead of displaying by doing wraptext in the cell, I thought to have a VBA text box, As soon as cell in clicked VBA text box will display the content in the text box
Function is working fine, however when I select a entire row, then I am getting VBA error.
run-time error 1004
Application-defined or object-defined error
VBA Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRgAddress As String
xRgAddress = "F11:f60"
If xRgAddress = "" Then
With TextBox1
.Top = Target.Top
.Left = Target.Offset(, 1).Left
.Text = Target.Text
.Visible = True
End With
Else
If Intersect(Target, Range(xRgAddress)) Is Nothing Then
TextBox1.Visible = False
Else
With TextBox1
.Top = Target.Top
.Left = Target.Offset(, 1).Left
.Text = Target.Text
.Visible = True
End With
End If
End If
End Sub
Could someone help me how this error can be avoided
I have long text in one of the cell, Instead of displaying by doing wraptext in the cell, I thought to have a VBA text box, As soon as cell in clicked VBA text box will display the content in the text box
Function is working fine, however when I select a entire row, then I am getting VBA error.
run-time error 1004
Application-defined or object-defined error
VBA Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRgAddress As String
xRgAddress = "F11:f60"
If xRgAddress = "" Then
With TextBox1
.Top = Target.Top
.Left = Target.Offset(, 1).Left
.Text = Target.Text
.Visible = True
End With
Else
If Intersect(Target, Range(xRgAddress)) Is Nothing Then
TextBox1.Visible = False
Else
With TextBox1
.Top = Target.Top
.Left = Target.Offset(, 1).Left
.Text = Target.Text
.Visible = True
End With
End If
End If
End Sub
Could someone help me how this error can be avoided