Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default calculating undefined ranges using vba


Can anyone help?

I need to calculate the total of any selected cells which all have th
same value. For example:
I have created a shortcut key (macro) and used vb to program a simpl
fill function when the user selects any range of cells and hits ctrl+r

So say the user selects any range - say a 2 column by 10 row area B6 t
B16 and C6 to C16. They then het ctrl+r - the area fills in red. I
every cell is equal to 13.25 (£) can the total cost of that space b
calculated and displayed? Again, the total needs to be able to b
calculated anywhere within the cells B6 to K59 (each cell would b
valued as 13.25 but this cannot appear on the spreadsheet).

Summed up, I guess you could say I'm looking to calculate the cost o
any selection defined by the user.

I really am very lost!

Hope this is clear!

rac

--
rach
-----------------------------------------------------------------------
rachy's Profile: http://www.excelforum.com/member.php...fo&userid=1506
View this thread: http://www.excelforum.com/showthread.php?threadid=26718

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default calculating undefined ranges using vba

be aware that CTRL R is the standard kb shortcut for FillRight.

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


rachy wrote:


Can anyone help?

I need to calculate the total of any selected cells which all have the
same value. For example:
I have created a shortcut key (macro) and used vb to program a simple
fill function when the user selects any range of cells and hits ctrl+r.

So say the user selects any range - say a 2 column by 10 row area B6 to
B16 and C6 to C16. They then het ctrl+r - the area fills in red. If
every cell is equal to 13.25 (£) can the total cost of that space be
calculated and displayed? Again, the total needs to be able to be
calculated anywhere within the cells B6 to K59 (each cell would be
valued as 13.25 but this cannot appear on the spreadsheet).

Summed up, I guess you could say I'm looking to calculate the cost of
any selection defined by the user.

I really am very lost!

Hope this is clear!

rach



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default calculating undefined ranges using vba

set rng = Range("B6:K59")
if union(selection,rng).Address < "$B$6:$K$59" then
' selection is not totally within B6:K59
msgbox "Invalid selection"
Else
msgbox Format(Selection.count * 13.25,"£#,##0.00")
End if

--
Regards,
Tom Ogilvy

"rachy" wrote in message
...

Can anyone help?

I need to calculate the total of any selected cells which all have the
same value. For example:
I have created a shortcut key (macro) and used vb to program a simple
fill function when the user selects any range of cells and hits ctrl+r.

So say the user selects any range - say a 2 column by 10 row area B6 to
B16 and C6 to C16. They then het ctrl+r - the area fills in red. If
every cell is equal to 13.25 (£) can the total cost of that space be
calculated and displayed? Again, the total needs to be able to be
calculated anywhere within the cells B6 to K59 (each cell would be
valued as 13.25 but this cannot appear on the spreadsheet).

Summed up, I guess you could say I'm looking to calculate the cost of
any selection defined by the user.

I really am very lost!

Hope this is clear!

rach


--
rachy
------------------------------------------------------------------------
rachy's Profile:

http://www.excelforum.com/member.php...o&userid=15065
View this thread: http://www.excelforum.com/showthread...hreadid=267187



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
Calculating ranges Connie New Users to Excel 2 January 19th 09 06:28 PM
Calculating within Date Ranges MB Excel Discussion (Misc queries) 3 October 9th 08 10:44 PM
Calculating Date Ranges Chris Hofer Excel Worksheet Functions 4 April 24th 07 09:46 PM
Calculating with named ranges KG Excel Discussion (Misc queries) 2 May 13th 05 02:52 PM
calculating date time ranges Patrick Excel Worksheet Functions 2 November 11th 04 05:07 AM


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