Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default writing a formula to a cell

Does anyone know why I get an error when I try to write this formula to a cell?

Range("A2").formula = "='LP-A'!E10"

where LP-A is the name of a sheet and E10 is the cell whose value that I
want to put in A2

I get a trappable error 1004 description is "Application - defined or
object-defined error"

Any help would be greatly appreciated!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default writing a formula to a cell

You sure that the name of that worksheet is LP-A?

Maybe extra (leading/trailing/embedded spaces)???

Maybe that worksheet doesn't exist in the activeworkbook.

Bobby Renfro wrote:

Does anyone know why I get an error when I try to write this formula to a cell?

Range("A2").formula = "='LP-A'!E10"

where LP-A is the name of a sheet and E10 is the cell whose value that I
want to put in A2

I get a trappable error 1004 description is "Application - defined or
object-defined error"

Any help would be greatly appreciated!


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default writing a formula to a cell

LP-A is the name of the sheet, and the worksheet is not protected. The
strange thing is that I can record a macro that executes when I push a
button. This macro correctly inserts the formula in the cell, but when my
code wants to put the formula in the cell using the same code as the formula
I get the error.

I can't figure it out.

"Dave Peterson" wrote:

You sure that the name of that worksheet is LP-A?

Maybe extra (leading/trailing/embedded spaces)???

Maybe that worksheet doesn't exist in the activeworkbook.

Bobby Renfro wrote:

Does anyone know why I get an error when I try to write this formula to a cell?

Range("A2").formula = "='LP-A'!E10"

where LP-A is the name of a sheet and E10 is the cell whose value that I
want to put in A2

I get a trappable error 1004 description is "Application - defined or
object-defined error"

Any help would be greatly appreciated!


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default writing a formula to a cell

Are you using xl97?

Are you running this code from a commandbutton from the control toolbox toolbar
placed on a worksheet? (Or any control from that control toolbox toolbar?)

If yes, try changing the .takefocusonclick property for that button to False.

If the control doesn't have that property, try adding:
activecell.activate

to the top of the code.

(This was a bug that was fixed in xl2k.)



Bobby Renfro wrote:

LP-A is the name of the sheet, and the worksheet is not protected. The
strange thing is that I can record a macro that executes when I push a
button. This macro correctly inserts the formula in the cell, but when my
code wants to put the formula in the cell using the same code as the formula
I get the error.

I can't figure it out.

"Dave Peterson" wrote:

You sure that the name of that worksheet is LP-A?

Maybe extra (leading/trailing/embedded spaces)???

Maybe that worksheet doesn't exist in the activeworkbook.

Bobby Renfro wrote:

Does anyone know why I get an error when I try to write this formula to a cell?

Range("A2").formula = "='LP-A'!E10"

where LP-A is the name of a sheet and E10 is the cell whose value that I
want to put in A2

I get a trappable error 1004 description is "Application - defined or
object-defined error"

Any help would be greatly appreciated!


--

Dave Peterson


--

Dave Peterson
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
Need help writing a formula lakwriter Excel Discussion (Misc queries) 3 November 2nd 09 03:04 PM
writing a formula chrissy Excel Worksheet Functions 4 November 3rd 08 08:24 PM
Relative/Absolute Formula writing in to a cell. Hari Prasadh[_2_] Excel Programming 1 February 3rd 05 10:41 AM
Writing Excel Formula To A Cell Nathan[_4_] Excel Programming 2 June 23rd 04 03:38 PM
Writing a formula into a cell Dr. Schwartz[_3_] Excel Programming 2 January 26th 04 01:31 PM


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