Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Placing TextBox text in cell

Use ActiveCell.Value instead of ActiveCell.Text... the Text property for a
Range object is Read Only.

Rick


"Patrick C. Simonds" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Placing TextBox text in cell

Hi Patrick,

My first guess would be that you need to set the TakeFocusOnClick
property of the CommandButton to False.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Patrick C. Simonds" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Placing TextBox text in cell

Anything like:

Sub fhakf()
ActiveCell.Text = "xxx"
End Sub

will fail since Text is read-only for Ranges.


Use ActiveCell.Value
--
Gary''s Student - gsnu200797


"Patrick C. Simonds" wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Placing Col & Row identifiers into a cell as text John Excel Worksheet Functions 3 May 28th 08 01:46 AM
Textbox text into cell as formula Zone Excel Programming 3 July 11th 06 06:38 PM
Finding a value and placing text on the cell to the right Reggie Excel Programming 4 April 5th 06 04:48 PM
take text from form textbox and put in cell... thomas Excel Programming 1 July 26th 05 01:35 AM
check variable(text) with cell (text), textbox Mark[_17_] Excel Programming 1 August 27th 03 01:15 PM


All times are GMT +1. The time now is 11:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"