ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Summarising figures - can anyone help please (https://www.excelbanter.com/excel-programming/285408-summarising-figures-can-anyone-help-please.html)

ian123[_16_]

Summarising figures - can anyone help please
 
I'd like to create a macro that allows me to do the following but i'm a
bit stuck - can anyone help?

I want to be able to select some numeric cells (a1, a7 a12, a56 for
exampel) and then run a macro which will sum the amounts and place the
total in the cell that is immediately to the right of the last cell
selected in the sum (eg, b56)

However, in addition to this i want all of these cells (a1,a7, a12, a56
and b56) to be highlighted in someway to show that they are linked -
i'm thinking a change of background color or the use of a numbered
key.

Any help on this would be very much appreciated


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

Summarising figures - can anyone help please
 
Sub Tester10()
Dim rng As Range, rng1 As Range
Set rng = Selection
Set rng1 = rng.Areas(rng.Areas.Count)
Set rng1 = rng1(rng1.Rows.Count, rng1.Columns.Count)
rng1.Offset(0, 1).Formula = "=Sum(" & rng.Address & ")"
Union(rng, rng1.Offset(0, 1)).Interior.ColorIndex = 5

End Sub

This is sensative to the order you select your cells.



--
Regards,
Tom Ogilvy


ian123 wrote in message
...
I'd like to create a macro that allows me to do the following but i'm a
bit stuck - can anyone help?

I want to be able to select some numeric cells (a1, a7 a12, a56 for
exampel) and then run a macro which will sum the amounts and place the
total in the cell that is immediately to the right of the last cell
selected in the sum (eg, b56)

However, in addition to this i want all of these cells (a1,a7, a12, a56
and b56) to be highlighted in someway to show that they are linked -
i'm thinking a change of background color or the use of a numbered
key.

Any help on this would be very much appreciated


---
Message posted from http://www.ExcelForum.com/




ian123[_17_]

Summarising figures - can anyone help please
 
Tom,

Thanks very much,that is excellent. However is it possible to include
the option to select which color to highlight the cell or change the
color each time its run.

Basically, it works fine the first time i summarise the data but if i
want to summarise two sets of data within the same range i am left with
two summaries with the same color - which confuses the issue somewhat!

Once again, many thanks - it is very much appreciated


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

Summarising figures - can anyone help please
 
Sub Tester10()
Dim rng As Range, rng1 As Range
Set rng = Selection
Set rng1 = rng.Areas(rng.Areas.Count)
Set rng1 = rng1(rng1.Rows.Count, rng1.Columns.Count)
rng1.Offset(0, 1).Formula = "=Sum(" & rng.Address & ")"
rng1.Offset(0, 1).Select
Application.Dialogs(xlDialogPatterns).Show
rng.Interior.ColorIndex = _
rng1.Offset(0, 1).Interior.ColorIndex
End Sub

--
Regards,
Tom Ogilvy


Tom Ogilvy wrote in message
...
Sub Tester10()
Dim rng As Range, rng1 As Range
Set rng = Selection
Set rng1 = rng.Areas(rng.Areas.Count)
Set rng1 = rng1(rng1.Rows.Count, rng1.Columns.Count)
rng1.Offset(0, 1).Formula = "=Sum(" & rng.Address & ")"
Union(rng, rng1.Offset(0, 1)).Interior.ColorIndex = 5

End Sub

This is sensative to the order you select your cells.



--
Regards,
Tom Ogilvy


ian123 wrote in message
...
I'd like to create a macro that allows me to do the following but i'm a
bit stuck - can anyone help?

I want to be able to select some numeric cells (a1, a7 a12, a56 for
exampel) and then run a macro which will sum the amounts and place the
total in the cell that is immediately to the right of the last cell
selected in the sum (eg, b56)

However, in addition to this i want all of these cells (a1,a7, a12, a56
and b56) to be highlighted in someway to show that they are linked -
i'm thinking a change of background color or the use of a numbered
key.

Any help on this would be very much appreciated


---
Message posted from http://www.ExcelForum.com/







All times are GMT +1. The time now is 02:16 AM.

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