I set up a spreadsheet so that you could edit a cell through a text box, the only problem is that it is limited to one column and when you select more than one cell, there is an error message. I have tried changing traget.column = 7 to target.range = ("A1:CA300") and target.adress = ("A:CA"), but nothing works.
Here is my working code:
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Dim PreviousCell As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 7 Then ActiveSheet.TextBox1.Text = Target
If Not PreviousCell Is Nothing Then
Debug.Print PreviousCell.Address
End If
Set PreviousCell = Target ' This needs to be the last line of code.
End Sub
Private Sub TextBox1_Change()
ActiveCell.Value = TextBox1
End Sub</code>
Here is my working code:
Code:
![File-Copy-icon.png](/board/proxy.php?image=http%3A%2F%2Ficons.iconarchive.com%2Ficons%2Fdouble-j-design%2Fravenna-3d%2F24%2FFile-Copy-icon.png&hash=7af35a7272028e9c5ca14222f1d8ed66)
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Dim PreviousCell As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 7 Then ActiveSheet.TextBox1.Text = Target
If Not PreviousCell Is Nothing Then
Debug.Print PreviousCell.Address
End If
Set PreviousCell = Target ' This needs to be the last line of code.
End Sub
Private Sub TextBox1_Change()
ActiveCell.Value = TextBox1
End Sub</code>