View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Martin Skrenek Martin Skrenek is offline
external usenet poster
 
Posts: 4
Default cell vs range problem with formula

Nice approach I didn't know that,
Thanks

"Snake Plissken" wrote in message
...

Użytkownik "Martin Skrenek" napisał w wiadomości
...
Hi,
i try to make a new workbook with two sheets named "Report" and "Data"
and put a formula there.

Public wbNew As Workbook
Set wbNew = Application.Workbooks.Add(ActiveWorkbook.Path & "\new.xlt")
...
a) wbNew.Worksheets("Report").Cells(1, 1).FormulaR1C1 =
"=round(Data!R1C1,1)"
b) wbNew.Worksheets("Report").Range("a1").FormulaR1C1 =
"=round(Data!R1C1,1)"
..

If I try to use a) with cells, in sheet there is is #name? error. When I
use F2 for editting e cell and I press Enter (nothing changed), it's OK
and calculates. When I use this approach in one workbook it works, but I
use one workbook from anoher.
If I try to use b) It works fine

Does anymody know whats the problem? For me it's better to use cells
property in my program.

Thanks,
Martin



try this:
a) wbNew.Worksheets("Report").Range(Cells(x1, x2),Cells(x3,
x4)).FormulaR1C1 = "=round(Data!R1C1,1)"

where x1, x2, x3, x4 are variables, or just put 1 instead of it