View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Patrick C. Simonds Patrick C. Simonds is offline
external usenet poster
 
Posts: 343
Default Object Variable error

Thanks, I changed that, but it still does not solve the problem.


"Joel" wrote in message
...
A cell doesn't have TEXT it should be VALUE.

TextBox1.Text = rng(1, 2).Value

"Patrick C. Simonds" wrote:

I use the following code below to populate the current cell on the
January
worksheet (there is a worksheet for each month, and each month has to
have
all the names that appear on the ParaTransit Names worksheet) with the
name
that is entered in the referenced cell on the ParaTransit Names
worksheet:

=IF('ParaTransit Names'!B15"",'ParaTransit Names'!B15,"")


I then use the following code to place the name contained in the active
cell
on the January worksheet in the TextBox of the UserForm:


Private Sub UserForm_Initialize()

Dim rng
Set rng = Cells(ActiveCell.Row, 1)

'Places date in box at top of userform

TextBox1.Text = rng(1, 2).Text

End Sub


What I was hoping for, is that when I ran the code below it would search
out
and select the cell matching the TextBox value on the ParaTransit Names
worksheet. What I get is an Error Msg "object variable or With block
variable not set". Any guidance here?




Private Sub CommandButton1_Click()

With ActiveWorkbook.Worksheets("ParaTransit Names")

Cells.Find(What:=Me.TextBox1.Text, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate

End With

End Sub