Formula to sum rows

G

Guest

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])"
 
B

Bob Phillips

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)
 
G

Guest

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


Bob Phillips said:
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 said:
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])"
 
G

Guest

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

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


Bob Phillips said:
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 said:
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])"
 
J

JMay

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

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 said:
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])"
 
G

Guest

TY JMay

JMay said:
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

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 said:
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])"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top