View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Patrick C. Simonds Patrick C. Simonds is offline
external usenet poster
 
Posts: 343
Default Placing TextBox text in cell

Can anyone tell me why I get an error (Object required) on the line:

ActiveCell.Text = TextBox2.Text

The code is run from a UserForm and is intended to replace the contents of
the active cell with the text in TextBox2



Private Sub CommandButton7_Click()
Dim rng As Range

Dim aSht As Worksheet
Dim aCel As Range
Set aSht = ActiveSheet
Set aCel = ActiveCell
Application.ScreenUpdating = False

ThisWorkbook.Sheets("paratransit names").Activate
Cells.Find(What:=TextBox1.Text, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate

ActiveCell.ClearContents
ActiveCell.Text = TextBox2.Text


aSht.Activate
aCel.Select

Application.ScreenUpdating = True
End Sub