Main Code
Macro Test
Hello there! I have a code that it intended to take information from cell AI2 and put it into text box TextBox5 by running Macro "Test" whenever any cell is selected, and it works! My issue that led to my using the code was that I wasn't able to get more than 255 characters from the cell to the text box without it, but now everything crosses over!
Now, my issue is that while the macro runs and everything updates smoothely whenever a new cell is selected, the cell that is clicked it immediately deselected and the text box is selected instead. How do I keep everything working, but stop deselecting the cells and selecting the text box automatically upon clicking any cell from in A1:AI200?
Thanks so much!
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("AI2").Value = ActiveCell.Address
Const WS_RANGE As String = "A1:AI200"
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Call Test
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
Macro Test
VBA Code:
Sub Test()
ActiveSheet.Shapes.Range(Array("TextBox5")).Select 'name of your shape/textbox
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Range("AI5").Value 'cell reference you want to get text from
'below adjusts formatting
ActiveSheet.Shapes.Range(Array("TextBox5")).Select
Selection.ShapeRange.TextFrame2.TextRange.Font.Size = 12
With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
.Visible = msoTrue
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
.Solid
End With
End Sub
Hello there! I have a code that it intended to take information from cell AI2 and put it into text box TextBox5 by running Macro "Test" whenever any cell is selected, and it works! My issue that led to my using the code was that I wasn't able to get more than 255 characters from the cell to the text box without it, but now everything crosses over!
Now, my issue is that while the macro runs and everything updates smoothely whenever a new cell is selected, the cell that is clicked it immediately deselected and the text box is selected instead. How do I keep everything working, but stop deselecting the cells and selecting the text box automatically upon clicking any cell from in A1:AI200?
Thanks so much!