ActiveCell.FormulaR1C1 = "=RC[-4]-RC[-2]"

J

Jordi

If I exectue this simple code :

Range("F8").Select
ActiveCell.FormulaR1C1 = "=RC[-4]-RC[-2]"

It works great if I execute if from the current workbook but if the code is
in another workbook and I include:
Windows("Libro1").Activate

It raises error 1004

Any help?
 
J

JON JON

Hello Jordi,

Check if the sheet that get the entry is not protected (Tools|Protection).
If it is protected you may want to include this into your code before the
entry

Activesheet.Unprotect
....you code here
Activesheet.Protect

If it is has password you need to type the password after the "Unprotect"
and "Protect".

Regards,

Jon-jon
 
J

Jordi

Isn't the case
but thank you.
Any other idea?

JON JON said:
Hello Jordi,

Check if the sheet that get the entry is not protected (Tools|Protection).
If it is protected you may want to include this into your code before the
entry

Activesheet.Unprotect
...you code here
Activesheet.Protect

If it is has password you need to type the password after the "Unprotect"
and "Protect".

Regards,

Jon-jon

Jordi said:
If I exectue this simple code :

Range("F8").Select
ActiveCell.FormulaR1C1 = "=RC[-4]-RC[-2]"

It works great if I execute if from the current workbook but if the code is
in another workbook and I include:
Windows("Libro1").Activate

It raises error 1004

Any help?
 
J

JON JON

I am trying to duplicate your scenario but could not get the same error.
Have you tried to debug? Where does the highlight go? I am suspecting that
it has something to do with the activate and select command. You may want
to avoid that and instead try something like

Workbooks("Book1").Sheets("Sheet1").Range("F8").FormulaR1C1 =
"=RC[-4]-RC[-2]"


Jordi said:
Isn't the case
but thank you.
Any other idea?

JON JON said:
Hello Jordi,

Check if the sheet that get the entry is not protected (Tools|Protection).
If it is protected you may want to include this into your code before the
entry

Activesheet.Unprotect
...you code here
Activesheet.Protect

If it is has password you need to type the password after the "Unprotect"
and "Protect".

Regards,

Jon-jon

Jordi said:
If I exectue this simple code :

Range("F8").Select
ActiveCell.FormulaR1C1 = "=RC[-4]-RC[-2]"

It works great if I execute if from the current workbook but if the
code
is
in another workbook and I include:
Windows("Libro1").Activate

It raises error 1004

Any help?
 
D

Don Guillett

try is with "book1.xls" assuming that it is OPEN.

--
Don Guillett
SalesAid Software
(e-mail address removed)
JON JON said:
I am trying to duplicate your scenario but could not get the same error.
Have you tried to debug? Where does the highlight go? I am suspecting that
it has something to do with the activate and select command. You may want
to avoid that and instead try something like

Workbooks("Book1").Sheets("Sheet1").Range("F8").FormulaR1C1 =
"=RC[-4]-RC[-2]"


Jordi said:
Isn't the case
but thank you.
Any other idea?

JON JON said:
Hello Jordi,

Check if the sheet that get the entry is not protected (Tools|Protection).
If it is protected you may want to include this into your code before the
entry

Activesheet.Unprotect
...you code here
Activesheet.Protect

If it is has password you need to type the password after the "Unprotect"
and "Protect".

Regards,

Jon-jon

If I exectue this simple code :

Range("F8").Select
ActiveCell.FormulaR1C1 = "=RC[-4]-RC[-2]"

It works great if I execute if from the current workbook but if the code
is
in another workbook and I include:
Windows("Libro1").Activate

It raises error 1004

Any help?
 
J

JON JON

I try both "Book1" and "Book1.xls" they will both work if the file is save
for the first time. However, if it is a new workbook, "Book1.xls" give me
subscript out range error.


Don Guillett said:
try is with "book1.xls" assuming that it is OPEN.

--
Don Guillett
SalesAid Software
(e-mail address removed)
JON JON said:
I am trying to duplicate your scenario but could not get the same error.
Have you tried to debug? Where does the highlight go? I am suspecting that
it has something to do with the activate and select command. You may want
to avoid that and instead try something like

Workbooks("Book1").Sheets("Sheet1").Range("F8").FormulaR1C1 =
"=RC[-4]-RC[-2]"


Jordi said:
Isn't the case
but thank you.
Any other idea?

"JON JON" <[email protected]> escribió en el mensaje
Hello Jordi,

Check if the sheet that get the entry is not protected (Tools|Protection).
If it is protected you may want to include this into your code
before
the
entry

Activesheet.Unprotect
...you code here
Activesheet.Protect

If it is has password you need to type the password after the "Unprotect"
and "Protect".

Regards,

Jon-jon

If I exectue this simple code :

Range("F8").Select
ActiveCell.FormulaR1C1 = "=RC[-4]-RC[-2]"

It works great if I execute if from the current workbook but if
the
code
is
in another workbook and I include:
Windows("Libro1").Activate

It raises error 1004

Any help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top