Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default combinations of checkboxes and executing commands


let's say i have 4 checkboxes, a, b, c, and d. i want to do some
calculation (e.g. the average) based on what is selected.

in other words, if a and b are chosen, it will be the average of a and
b. if a, b, and c are chosen, then it will be the average of a, b, and
c.

now, of course, if i hard code this as a bunch of if-then statements,
it will be cumbersome, as i'll have to code every single possible
combination (a; b; c; d; a and b; a and c; etc.).

is there a more efficient way to do this?

thanks.


--
dreamz
------------------------------------------------------------------------
dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
View this thread: http://www.excelforum.com/showthread...hreadid=479943

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default combinations of checkboxes and executing commands


nevermind, i have a question.

how do i make it so that the formula is pasted into a cell rather than
a value?


--
dreamz
------------------------------------------------------------------------
dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
View this thread: http://www.excelforum.com/showthread...hreadid=479943

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default combinations of checkboxes and executing commands

if chkA.value then
wcount=wcount+1
dValue = dValue + A
endif
if chkB.value then
wcount=wcount+1
dValue = dValue + B
endif
if chkC.value then
wcount=wcount+1
dValue = dValue + C
endif

and so on.
then average is dvalue/wcount.
Hope this helps.

Alok

"dreamz" wrote:


let's say i have 4 checkboxes, a, b, c, and d. i want to do some
calculation (e.g. the average) based on what is selected.

in other words, if a and b are chosen, it will be the average of a and
b. if a, b, and c are chosen, then it will be the average of a, b, and
c.

now, of course, if i hard code this as a bunch of if-then statements,
it will be cumbersome, as i'll have to code every single possible
combination (a; b; c; d; a and b; a and c; etc.).

is there a more efficient way to do this?

thanks.


--
dreamz
------------------------------------------------------------------------
dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
View this thread: http://www.excelforum.com/showthread...hreadid=479943


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default combinations of checkboxes and executing commands

Hi,
The way to do it is
Worksheets("abc").Cells(1,2).FormulaR1C1="=Sum(myr ange)"

By the way when you are asking a new question it is advisable to start a new
thread. Otherwise people may not pay attention to your new query. :-)

Alok


"dreamz" wrote:


nevermind, i have a question.

how do i make it so that the formula is pasted into a cell rather than
a value?


--
dreamz
------------------------------------------------------------------------
dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
View this thread: http://www.excelforum.com/showthread...hreadid=479943


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default combinations of checkboxes and executing commands


thanks, alok. i wrote something like this. to be clear, i declare
tricor and oos as ranges.


Code
-------------------
If radOverall Then

If chTricor Then
Set Tricor = Range("RankTricorAll")
TricorCount = 1
Else
Set Tricor = shRankings.Range("B3")
TricorCount = 0
End If

If chOOS Then
Set OOS = Range("RankOOSAll")
OOSCount = 1
Else
Set OOS = shRankings.Range("B3")
OOSCount = 0
End If

shRankings.Range("AverageAll").Formula = Tricor + OOS

End I
-------------------


and that didn't work. it said type mismatch error. what did i do wrong
(don't worry about the count stuff for now. i didn't include it in th
formula because i'm still testing it).


and it's not an entirely new question since it's just a problem
encountered when trying to implement the solution to this one. i don'
like creating multiple threads, as it seems like spam

--
dream
-----------------------------------------------------------------------
dreamz's Profile: http://www.excelforum.com/member.php...fo&userid=2646
View this thread: http://www.excelforum.com/showthread.php?threadid=47994

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
Why are my functions not executing? Charlie Excel Worksheet Functions 1 March 3rd 09 11:21 PM
Forumlas Not Executing Trey Excel Discussion (Misc queries) 2 January 25th 06 04:02 PM
Worksheet_Change Still Not Executing.... [email protected] Excel Programming 0 September 3rd 04 11:50 PM
Worksheet_Change Still Not Executing.... [email protected] Excel Programming 0 September 3rd 04 05:26 AM
Code Changes Not Executing Justin[_8_] Excel Programming 1 October 24th 03 02:31 AM


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