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

Hello

I have the above error msg on this line:-

Private Sub cmdAddBtn1_Click()
ActiveWorkbook.Sheets("HEA Payments").Activate

Sheets("HEA Payments").Range("A1").End(xlDown).Offset(1, 0).Select


What is wrong or how do i reference it?

Tx.


garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application / Object Error 1004

Your code ran fine for me.

Code was in the worksheet module of a sheet having cmdAddBtn1 and this
sheet was not HEA Payments.
HEA Payments and the sheet with the code were in the same workbook.
--
Regards,
Tom Ogilvy

"Garry" wrote in message
...
Hello

I have the above error msg on this line:-

Private Sub cmdAddBtn1_Click()
ActiveWorkbook.Sheets("HEA Payments").Activate

Sheets("HEA Payments").Range("A1").End(xlDown).Offset(1, 0).Select


What is wrong or how do i reference it?

Tx.


garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Application / Object Error 1004

Tom

Is was working fine for me then started with that error??

The actual worksheet is on a network drive that everyone has access
too?? full path is F:\hea..\...\payments.xls.

Having said that no-one should be accessing it as they would not know it
was actually there.

Are there any flags or settings that I should be resetting?


garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application / Object Error 1004

If it is in another workbook, then the code should be

Private Sub cmdAddBtn1_Click()
ActiveWorkbook.Sheets("HEA Payments").Activate
Activeworkbook.Sheets("HEA Payments").Range("A1") _
.End(xlDown).Offset(1, 0).Select

End Sub

--
Regards,
Tom Ogilvy


"Garry" wrote in message
...
Tom

Is was working fine for me then started with that error??

The actual worksheet is on a network drive that everyone has access
too?? full path is F:\hea..\...\payments.xls.

Having said that no-one should be accessing it as they would not know it
was actually there.

Are there any flags or settings that I should be resetting?


garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Application / Object Error 1004


Tom

Tx for the quick reply.

No that didn't work either. I tried a reboot too.

Could I be Activating the workbook/sheet too many times?

What would be the fully qualified statement?

Tx
garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application / Object Error 1004

Well there is no way to click a button on a worksheet and have another
workbook be the activeworkbook - should have recognized that fallacy from
the start. If you want to select a range in another workbook, you would
need to activate that workbook first.

Private Sub cmdAddBtn1_Click()
Workbooks("HEA Payments.xls").Activate
ActiveWorkbook.Sheets("HEA Payments").Activate
Activeworkbook.Sheets("HEA Payments").Range("A1") _
.End(xlDown).Offset(1, 0).Select

End Sub

Change the first line of code to reflect the actual name of the workbook.

--
Regards,
Tom Ogilvy


"Garry" wrote in message
...

Tom

Tx for the quick reply.

No that didn't work either. I tried a reboot too.

Could I be Activating the workbook/sheet too many times?

What would be the fully qualified statement?

Tx
garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Application / Object Error 1004


Tom

Tried that but still the same.

I tried moving it all to the initialise stetement when the form loads
but no effect.
So done this on a new workbook

Private Sub CommandButton1_Click()
Workbooks("test.xls").Activate
ActiveWorkbook.Sheets("Sheet1").Activate
ActiveWorkbook.Sheets("Sheet1").Range("A1") _
.End(xlDown).Offset(1, 0).Select

MsgBox "done that"
End Sub

Same error at the same point??

Is it me?? I have winxp pro and excel 2000
garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application / Object Error 1004

I created a userform in a new workbook (not test.xls), put one commandbutton
on it and pasted in your code.

I then had workbook Test.xls open, but not active. I showed the userform
and clicked the commandbutton and it ran fine for me. (as expected).

Win 2000 and Excel 2002 but I have done similar in xl97, xl2000, Win 98SE

The only thing I can think of that would cause this error is if there is no
Data below A1. If you do End(xldown) and the column is empty you end up at
A65536, then trying to offset 1 cell below that (which doesn't exist) would
cause a 1004 error. If that is not the case then:

You can try application.Goto

Private Sub CommandButton1_Click()
Application.Goto workbooks("Test.xls"). _
Worksheets("Sheet1").Range("A1").End(xldown).Offse t(1,0)
End Sub

Or you can just reference that cell and not try to select it
Dim rng as Range
set rng = workbooks("Test.xls"). _
Worksheets("Sheet1").Range("A1").End(xldown).Offse t(1,0)
rng.Value = 21

--
Regards,
Tom Ogilvy



"Garry" wrote in message
...

Tom

Tried that but still the same.

I tried moving it all to the initialise stetement when the form loads
but no effect.
So done this on a new workbook

Private Sub CommandButton1_Click()
Workbooks("test.xls").Activate
ActiveWorkbook.Sheets("Sheet1").Activate
ActiveWorkbook.Sheets("Sheet1").Range("A1") _
.End(xlDown).Offset(1, 0).Select

MsgBox "done that"
End Sub

Same error at the same point??

Is it me?? I have winxp pro and excel 2000
garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Error 1004 Application Defined or Object Defined Error Garry[_6_] Excel Programming 2 October 1st 04 10:33 AM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM
"Run Time Error 1004 Application Defined or Object Defined Error." BJC Excel Programming 4 October 26th 03 03:09 AM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM


All times are GMT +1. The time now is 10:24 AM.

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

About Us

"It's about Microsoft Excel"