Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
How to assign same code inside Option button code space ?? | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming |