Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Object Required Error

Hello. Anyone see a problem with the below code? A button calls the
Userform. The enter button on the user form calls the Private sub, and if
the if statement is validated, the private calls the Sub Write_Data. Is the
problem with variables across sub modules?

If UserForm1.Caption = "New Project" Then

With Worksheets("Data")
Set newRow = .Cells(Rows.Count, "F").End(xlUp).Offset(1, 5)
End With
Write_Data
Else

Sub Write_Data()
newRow.Offset(0, 4).Value = NewBase.TextBox1.Text
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Object Required Error

the variable/object NewBase is not defined in Write_Data, so unless it is a
global variable or the name of a userform, it would be undefined.
the easiest way to check your variable visbility is to put Option Explict at
the top of all your modules and then compile the project.

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hello. Anyone see a problem with the below code? A button calls the
Userform. The enter button on the user form calls the Private sub, and if
the if statement is validated, the private calls the Sub Write_Data. Is

the
problem with variables across sub modules?

If UserForm1.Caption = "New Project" Then

With Worksheets("Data")
Set newRow = .Cells(Rows.Count, "F").End(xlUp).Offset(1, 5)
End With
Write_Data
Else

Sub Write_Data()
newRow.Offset(0, 4).Value = NewBase.TextBox1.Text
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Object Required Error

Hi Tom,

Sorry, missed that typo. Should have read:

If NewBase.Caption = "New Project" Then
With Worksheets("Data")
Set newRow = .Cells(Rows.Count, "F").End(xlUp).Offset(1, 5)
End With
Write_Data
Else

Sub Write_Data()
newRow.Offset(0, 4).Value = NewBase.TextBox1.Text
End Sub

Where NewBase is the name of the form. I tried to compile after option
explicit, but got an out of memory error?

"Tom Ogilvy" wrote in message
...
the variable/object NewBase is not defined in Write_Data, so unless it is

a
global variable or the name of a userform, it would be undefined.
the easiest way to check your variable visbility is to put Option Explict

at
the top of all your modules and then compile the project.

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hello. Anyone see a problem with the below code? A button calls the
Userform. The enter button on the user form calls the Private sub, and

if
the if statement is validated, the private calls the Sub Write_Data. Is

the
problem with variables across sub modules?

If UserForm1.Caption = "New Project" Then

With Worksheets("Data")
Set newRow = .Cells(Rows.Count, "F").End(xlUp).Offset(1, 5)
End With
Write_Data
Else

Sub Write_Data()
newRow.Offset(0, 4).Value = NewBase.TextBox1.Text
End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Object Required Error

Is suspect Write_Data can not see the variable NewRow (unless it is global
to the module).

Dim newRow as Range
If NewBase.Caption = "New Project" Then
With Worksheets("Data")
Set newRow = .Cells(Rows.Count, "F").End(xlUp).Offset(1, 5)
End With
Write_Data newRow
Else

Sub Write_Data(Cell as Range)
cell.Offset(0, 4).Value = NewBase.TextBox1.Text
End Sub




--
Regards,
Tom Ogilvy


"Steph" wrote in message
...
Hi Tom,

Sorry, missed that typo. Should have read:

If NewBase.Caption = "New Project" Then
With Worksheets("Data")
Set newRow = .Cells(Rows.Count, "F").End(xlUp).Offset(1, 5)
End With
Write_Data
Else

Sub Write_Data()
newRow.Offset(0, 4).Value = NewBase.TextBox1.Text
End Sub

Where NewBase is the name of the form. I tried to compile after option
explicit, but got an out of memory error?

"Tom Ogilvy" wrote in message
...
the variable/object NewBase is not defined in Write_Data, so unless it

is
a
global variable or the name of a userform, it would be undefined.
the easiest way to check your variable visbility is to put Option

Explict
at
the top of all your modules and then compile the project.

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hello. Anyone see a problem with the below code? A button calls the
Userform. The enter button on the user form calls the Private sub,

and
if
the if statement is validated, the private calls the Sub Write_Data.

Is
the
problem with variables across sub modules?

If UserForm1.Caption = "New Project" Then

With Worksheets("Data")
Set newRow = .Cells(Rows.Count, "F").End(xlUp).Offset(1, 5)
End With
Write_Data
Else

Sub Write_Data()
newRow.Offset(0, 4).Value = NewBase.TextBox1.Text
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
Object required - run time error 424. devorivivere Excel Programming 3 April 10th 04 05:43 PM
runtime error ....object required mlm Excel Programming 3 February 18th 04 06:09 PM
object required error message goss[_10_] Excel Programming 6 January 23rd 04 10:22 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
error 424 - Object Required blb Excel Programming 0 October 1st 03 05:32 PM


All times are GMT +1. The time now is 05:54 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"