Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to add via programming ?

I need to open a file, count the occupied rows, and then total column C,
three rows below the last occupied row. I tried using the FormulaR1C1
option, but got confused on how to place the value of the variable, used to
count occupied rows.

Any ideas

Milind


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.514 / Virus Database: 312 - Release Date: 8/28/2003


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default How to add via programming ?

Milind,

Dim cRows As Long

cRows = Cells(Rows.Count, "C").End(xlUp).row
Cells(cRows + 3, "C").FormulaR1C1 = "=SUM(R1C:R[-3]C)"


Haven't bothered with the file open bit, as I assume you already have that.

--

HTH

Bob Phillips

"Milind" wrote in message
...
I need to open a file, count the occupied rows, and then total column C,
three rows below the last occupied row. I tried using the FormulaR1C1
option, but got confused on how to place the value of the variable, used

to
count occupied rows.

Any ideas

Milind


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.514 / Virus Database: 312 - Release Date: 8/28/2003




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default How to add via programming ?

One way:

With Range("C" & Rows.Count).End(xlUp).Offset(3, 0)
.Formula = "=SUM(C1:C" & .Row - 3 & ")"
End With

or

With Range("C" & Rows.Count).End(xlUp).Offset(3, 0)
.FormulaR1C1 = "=SUM(R1C:R[-3]C)"
End With


In article ,
"Milind" wrote:

I need to open a file, count the occupied rows, and then total column C,
three rows below the last occupied row. I tried using the FormulaR1C1
option, but got confused on how to place the value of the variable, used to
count occupied rows.

Any ideas

Milind


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.514 / Virus Database: 312 - Release Date: 8/28/2003


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default How to add via programming ?

Milind,

Dim lrow As Long
' lrow = last used row in column C

lrow = Cells(Rows.COUNT, "C").End(xlUp).Row

Cells(lrow +3,3).FormulaR1C1 = "=Sum(R1C3:R" & lrow & "C3)"

or

Range("C" & lrow + 3).Formula = "Sum(C1:C" & lrow & ")"

--
sb
"Milind" wrote in message
...
I need to open a file, count the occupied rows, and then total column C,
three rows below the last occupied row. I tried using the FormulaR1C1
option, but got confused on how to place the value of the variable, used

to
count occupied rows.

Any ideas

Milind


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.514 / Virus Database: 312 - Release Date: 8/28/2003




Reply
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
VBA Programming [email protected] New Users to Excel 2 May 28th 08 08:38 PM
Programming dim Excel Discussion (Misc queries) 7 November 16th 07 11:56 AM
programming help Stan Excel Discussion (Misc queries) 2 April 23rd 07 02:44 PM
Programming help BB Excel Discussion (Misc queries) 3 December 5th 05 01:09 AM
Do I need programming for this? .NET Developer Excel Programming 2 August 18th 03 08:55 PM


All times are GMT +1. The time now is 04:31 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"