#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default VBA code ??

The following code works when the DATAX sheet is activated; but when another
sheet is selected/activated, it generates an error "1004
Application-defined or Object-defined error"

can someone tell me what I did wrong??

Worksheets("DATAX").Range(Cells(3, 9), Cells(beginrow - 1, 9)).Formula =
Worksheets("DATAX").Cells(3, 9).Formula
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA code ??

With Worksheets("DATAX")
.Range(.Cells(3, 9), .Cells(beginrow - 1, 9)).Formula =
.Cells(3, 9).Formula
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul" wrote in message
...
The following code works when the DATAX sheet is activated; but when
another
sheet is selected/activated, it generates an error "1004
Application-defined or Object-defined error"

can someone tell me what I did wrong??

Worksheets("DATAX").Range(Cells(3, 9), Cells(beginrow - 1, 9)).Formula =
Worksheets("DATAX").Cells(3, 9).Formula



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default VBA code ??

Thanks Bob Phillips,

it still works on the datax page but not when another sheet is active. here
is all the code along with your suggested change:

Sub alt_ma780()
Dim beginrow As Integer
Dim FRML As String
Dim ma As Integer
ma = InputBox("ENTER MA", "# MA ROWS", 500)
If ma < 10 Then End
Worksheets("DATAX").Cells(1, 9) = "DELTA " & ma
beginrow = ma + 3
FRML = "=((I" & beginrow - 1 & "*" & ma & ")-F3+F" & beginrow & ")/" & ma
With Worksheets("DATAX")
.Range(Cells(3, 9), Cells(beginrow - 1, 9)).Formula =
Worksheets("DATAX").Cells(3, 9).Formula
End With
Worksheets("DATAX").Cells(beginrow, 9).Formula = FRML
Worksheets("DATAX").Range(Cells(beginrow, 9), Cells(4015, 9)).Formula =
Worksheets("DATAX").Cells(beginrow, 9).Formula
End Sub




"Bob Phillips" wrote:

With Worksheets("DATAX")
.Range(.Cells(3, 9), .Cells(beginrow - 1, 9)).Formula =
.Cells(3, 9).Formula
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul" wrote in message
...
The following code works when the DATAX sheet is activated; but when
another
sheet is selected/activated, it generates an error "1004
Application-defined or Object-defined error"

can someone tell me what I did wrong??

Worksheets("DATAX").Range(Cells(3, 9), Cells(beginrow - 1, 9)).Formula =
Worksheets("DATAX").Cells(3, 9).Formula




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default VBA code ??

You didn't incorporate all of Bob's changes. Instead of

Cells(...)

which defaults to the active sheet, you need to use the qualified

.Cells(...)

In article ,
Paul wrote:

Thanks Bob Phillips,

it still works on the datax page but not when another sheet is active. here
is all the code along with your suggested change:

Sub alt_ma780()
Dim beginrow As Integer
Dim FRML As String
Dim ma As Integer
ma = InputBox("ENTER MA", "# MA ROWS", 500)
If ma < 10 Then End
Worksheets("DATAX").Cells(1, 9) = "DELTA " & ma
beginrow = ma + 3
FRML = "=((I" & beginrow - 1 & "*" & ma & ")-F3+F" & beginrow & ")/" & ma
With Worksheets("DATAX")
.Range(Cells(3, 9), Cells(beginrow - 1, 9)).Formula =
Worksheets("DATAX").Cells(3, 9).Formula
End With
Worksheets("DATAX").Cells(beginrow, 9).Formula = FRML
Worksheets("DATAX").Range(Cells(beginrow, 9), Cells(4015, 9)).Formula =
Worksheets("DATAX").Cells(beginrow, 9).Formula
End Sub




"Bob Phillips" wrote:

With Worksheets("DATAX")
.Range(.Cells(3, 9), .Cells(beginrow - 1, 9)).Formula =
.Cells(3, 9).Formula
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul" wrote in message
...
The following code works when the DATAX sheet is activated; but when
another
sheet is selected/activated, it generates an error "1004
Application-defined or Object-defined error"

can someone tell me what I did wrong??

Worksheets("DATAX").Range(Cells(3, 9), Cells(beginrow - 1, 9)).Formula =
Worksheets("DATAX").Cells(3, 9).Formula




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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
How to assign same code inside Option button code space ?? furbiuzzu Excel Programming 1 November 21st 06 02:36 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


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