#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Error 1004

Hi,

Can anyone please help with the following:
1004 Application-defined or object-defined error.

....... lots of code

xstart = "555"
For j = 1 To nump
Debug.Print Worksheets("Sheet2").Cells(j, 1).Value, xstart
Worksheets("Sheet2").Cells(j, 1).Value = xstart

....... lots more code

The debug.print prints the correct values from the spreadsheet and the
program variable. It gives the error on the next line when trying to
set the value.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Error 1004

The little snippet of code you pasted worked ok for me (after adding some
declares and initializing variables).

Are you running xl97 and calling the code using a control from the control
toolbox toolbar.

If that's the case, change the .takefocusonclick property to false for that
control. If it doesn't have that property, add this line to the top of your
code:

Tigger wrote:

Hi,

Can anyone please help with the following:
1004 Application-defined or object-defined error.

...... lots of code

xstart = "555"
For j = 1 To nump
Debug.Print Worksheets("Sheet2").Cells(j, 1).Value, xstart
Worksheets("Sheet2").Cells(j, 1).Value = xstart

...... lots more code

The debug.print prints the correct values from the spreadsheet and the
program variable. It gives the error on the next line when trying to
set the value.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Error 1004

Dave,

Thanks for your reply. I have fixed the problem. Your mention of
'running' the code triggered the solution. This code was originally run
as a VB script. I cut/pasted it into VBA as a FUNCTION - hence I cannot
modify a cell etc. Duh!!

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
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM
Interior class error/runtime error 1004 David Goodall Excel Programming 1 October 24th 04 10:16 PM


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

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"