ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   finding two cells to sum (https://www.excelbanter.com/excel-programming/361485-finding-two-cells-sum.html)

Hru48[_20_]

finding two cells to sum
 

Hey,

I need a statement to put in a macro that will find two cells and sum
them putting the result in cell d4. The first cell is always d7 but the
second cell moves about every time the data is updated.

I'm at a bit of a loss as to how to find the second cell, it is always
3 to the left of a cell named sales so I thought I may be search for
the cell 'sales' and then use then use offset to get the cell 3 to the
left and then define a name for it so I could use it in the sum... but
this doesn't work as it gives the cell a reference rather then calling
it active.cell.

Can anyone this of a way of doing this? As I am a wee bit stumped.

Cheers

Hayley


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=542085


Don Guillett

finding two cells to sum
 
If your cell is really named sales then this formula will do it.
=D7+OFFSET(sales,0,-5)
by macro
Sub salesplus()
Range("b7") = Range("d7") + Range("sales")
End Sub

If you are looking for "sales" as text use this
If sales is always in col D use
columns(4).find
instead for better efficiency.

Sub findSALES()
Range("b4") = Range("d7") _
+ Cells.Find("sales").Offset(0, -5)
End Sub

--
Don Guillett
SalesAid Software

"Hru48" wrote in
message ...

Hey,

I need a statement to put in a macro that will find two cells and sum
them putting the result in cell d4. The first cell is always d7 but the
second cell moves about every time the data is updated.

I'm at a bit of a loss as to how to find the second cell, it is always
3 to the left of a cell named sales so I thought I may be search for
the cell 'sales' and then use then use offset to get the cell 3 to the
left and then define a name for it so I could use it in the sum... but
this doesn't work as it gives the cell a reference rather then calling
it active.cell.

Can anyone this of a way of doing this? As I am a wee bit stumped.

Cheers

Hayley


--
Hru48
------------------------------------------------------------------------
Hru48's Profile:
http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=542085




Hru48[_21_]

finding two cells to sum
 

Works grand cheers


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=542085


Don Guillett

finding two cells to sum
 
glad one of them helped

--
Don Guillett
SalesAid Software

"Hru48" wrote in message
...

Works grand cheers


--
Hru48
------------------------------------------------------------------------
Hru48's Profile:
http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=542085





All times are GMT +1. The time now is 06:14 AM.

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