ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activecell.FormulaR1C1 Versus ActiveSheet.cells(column, row) (https://www.excelbanter.com/excel-programming/291401-activecell-formular1c1-versus-activesheet-cells-column-row.html)

Ashish Shridharan

Activecell.FormulaR1C1 Versus ActiveSheet.cells(column, row)
 
H
Can anyone explain the difference between the following two methodologies of accessing and writing data to a cell in an excel sheet

1. using
range(column : row).selec
activecell.formular1c1 = <data OR activecell.text = <data

2. Usin
activesheet.cells(column, row) = <data

I have actually seen an application in the last couple of days that was using option 2 to write data to the excel sheet. The only problem was that Excel would continue to remain in memory even though QUIT, setting to nothing was being done on the excel variable instance

However, when i change the code to use Option 1, the excel object was removed from memory

Didnt make sense to me at all. Was hoping that someone could explain this to me

Thank

Ashish Shridharan

Bob Phillips[_6_]

Activecell.FormulaR1C1 Versus ActiveSheet.cells(column, row)
 
Ashish,

Apart from the syntax of the former being wrong, they are basically the
same, with one big proviso. The first does a select, which means that the
sheet being worked upon has to be active and visible so that the screen can
be re-painted.

So 1 does a select and then writes to the selected cell.

The second writes directly to a nominated cell, no selection involved.

As for the memory issue, I do not find this problem in my testing. Both
times Excel clears correctly. Is this being done through automation?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ashish Shridharan" wrote in message
...
Hi
Can anyone explain the difference between the following two methodologies

of accessing and writing data to a cell in an excel sheet ?

1. using
range(column : row).select
activecell.formular1c1 = <data OR activecell.text

= <data

2. Using
activesheet.cells(column, row) = <data


I have actually seen an application in the last couple of days that was

using option 2 to write data to the excel sheet. The only problem was that
Excel would continue to remain in memory even though QUIT, setting to
nothing was being done on the excel variable instance.

However, when i change the code to use Option 1, the excel object was

removed from memory.

Didnt make sense to me at all. Was hoping that someone could explain this

to me.

Thanks

Ashish Shridharan




Ashish Shridharan[_2_]

Activecell.FormulaR1C1 Versus ActiveSheet.cells(column, row)
 
Hi Bo

The app is a classic ASP app calling a component that generates the Excel file with the data

I couldnt really think of a co-relation between the two but i did see this happen and Excel did go away the minute i changed the code to a Range.select methodology

Thanks
Ashish


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com