#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Formula to sum rows

I have a database query that runs by a date range which can return different
amount of data based on date range this is the formula that i hand type into
cells
Can someone maybe help me with a formula to run a macro for this

Thanks mike

Range("G12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]-RC[-3])"
Range("H12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]*RC[-1])"
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Formula to sum rows

It would help if you gave us a bit more information, what does the data look
like, what does the macro need to do?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Mike" wrote in message
...
I have a database query that runs by a date range which can return
different
amount of data based on date range this is the formula that i hand type
into
cells
Can someone maybe help me with a formula to run a macro for this

Thanks mike

Range("G12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]-RC[-3])"
Range("H12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]*RC[-1])"



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Formula to sum rows

Column G
=SUM(E12-D12) ' Subtracts the New Price from Old Price
Column H
=SUM(F12*G12) ' New Price * QTY


"Bob Phillips" wrote:

It would help if you gave us a bit more information, what does the data look
like, what does the macro need to do?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Mike" wrote in message
...
I have a database query that runs by a date range which can return
different
amount of data based on date range this is the formula that i hand type
into
cells
Can someone maybe help me with a formula to run a macro for this

Thanks mike

Range("G12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]-RC[-3])"
Range("H12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]*RC[-1])"




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Formula to sum rows

Would like the macro to only go down as for as data does not all the way down
to row 65500

"Mike" wrote:

Column G
=SUM(E12-D12) ' Subtracts the New Price from Old Price
Column H
=SUM(F12*G12) ' New Price * QTY


"Bob Phillips" wrote:

It would help if you gave us a bit more information, what does the data look
like, what does the macro need to do?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Mike" wrote in message
...
I have a database query that runs by a date range which can return
different
amount of data based on date range this is the formula that i hand type
into
cells
Can someone maybe help me with a formula to run a macro for this

Thanks mike

Range("G12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]-RC[-3])"
Range("H12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]*RC[-1])"




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 422
Default Formula to sum rows

Sub Foo()
lr = Cells(Rows.Count, "E").End(xlUp).Row ' obtain last active row
For i = lr To 2 Step -1
Cells(i, 7).FormulaR1C1 = "=(RC[-1]-RC[-2])" '7 used for Column G
Next i
End Sub

"Bob Phillips" wrote in message
:

It would help if you gave us a bit more information, what does the data look
like, what does the macro need to do?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Mike" wrote in message
...
I have a database query that runs by a date range which can return
different
amount of data based on date range this is the formula that i hand type
into
cells
Can someone maybe help me with a formula to run a macro for this

Thanks mike

Range("G12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]-RC[-3])"
Range("H12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]*RC[-1])"




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Formula to sum rows

TY JMay

"JMay" wrote:

Sub Foo()
lr = Cells(Rows.Count, "E").End(xlUp).Row ' obtain last active row
For i = lr To 2 Step -1
Cells(i, 7).FormulaR1C1 = "=(RC[-1]-RC[-2])" '7 used for Column G
Next i
End Sub

"Bob Phillips" wrote in message
:

It would help if you gave us a bit more information, what does the data look
like, what does the macro need to do?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Mike" wrote in message
...
I have a database query that runs by a date range which can return
different
amount of data based on date range this is the formula that i hand type
into
cells
Can someone maybe help me with a formula to run a macro for this

Thanks mike

Range("G12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]-RC[-3])"
Range("H12").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-2]*RC[-1])"



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
copy formula every x rows andresg1975 Excel Worksheet Functions 5 October 30th 06 11:32 PM
Formula for Duplicating Rows!! GOL Excel Discussion (Misc queries) 2 May 22nd 06 08:54 PM
I get error with "ROWS" in the formula - nested formula question Marie J-son Excel Worksheet Functions 0 January 4th 06 02:55 PM
Insert rows, keep a formula? tb Excel Worksheet Functions 1 April 23rd 05 03:41 PM
can you hide rows with a formula? david Charts and Charting in Excel 1 April 8th 05 01:18 PM


All times are GMT +1. The time now is 03:31 PM.

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

About Us

"It's about Microsoft Excel"