LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Range.Formula and Range question using Excel Automation


I can't think of a way other than to evaluate the formula as you are
already doing.

Regarding your method for finding "sum", any reason you are not using
the VBA ".Find" (and FindNext) to speed up your search?

Below is the example shown in Help.
I've used it many times with "lookin:=xlValues", but not for
xlFormulas (which I think is how you'd do it); but it should work.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


On 18 Sep 2003 16:41:10 -0700, (Alfred) wrote:

Using Excel Automation, I'd like to try and open up an Excel file and
locate any cell which is summing the columns above it.

My current train of though was to cycle through all the cells and look
at Range.Formula, searching for a "=sum". However, this is not exact
enough as I could have a cell in a row which is totalling the rows
contents rather than the column itself. In which case I'd like to
continue searching.

That led me to the idea when I found a "=sum", to look at the
parameter of the sum() function and check if that range is located in
the column of the cell. If it is, then I would be assured the cell is
summing the column.

Any ideas or suggestions on other ways of tackling the problem?
Quicker methods?

A snippet of my code follows.

---------

for(int i = rows.Count; i 0; i--)
{
for(int k = 1; k < columns.Count + 1; k++)
{
cell = (Excel.Range)range.Cells[i,k];

if(((string)cell.Formula).ToLower().StartsWith("=s um"))
{
// we have some type of formula in this cell, do some processing

}
}
}


 
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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Automation of change of data range KIOhio Charts and Charting in Excel 4 June 30th 09 04:55 AM
Question on Named range with formula DocBrown Excel Worksheet Functions 2 June 5th 09 01:30 AM
formula for range values question webadict2be Excel Discussion (Misc queries) 4 February 7th 06 12:49 AM
variable range automation Ryan Proudfit Charts and Charting in Excel 1 March 31st 05 01:46 AM


All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"