[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

list animals with average capture_percent (Josh Susser's example

richter.josef

5/21/2008 12:29:00 PM

Hi guys,

I implemented self-referential system based on Josh Susser's guidance
on http://blog.hasmanythrough.co... … ny-through

now I'm unsuccesfully trying to list all animals together with average
hunt.capture_percent, regardless of whether it is 'pursuit' or
'escape' (i am using it on sthg else than animals where it makes sense
not to differentiate between these. i want to keep having separated
'pursuit' and 'escape' for future though)

i tried sthg like

<%= (animal.pursuit.average(:capture_percent)
+animal.pursuit.average(:capture_percent))/2 %>

first, this doesn't work, while having just <%=
(animal.pursuit.average(:capture_percent) %> does

second, i believe this calculation should rather be included in
controller, but i have no idea how to do it over an array, join this
array with the array of @animals and send this all to view :-(

this might be rather stupid newbie question, but I failed to google
out an answer :-( thanks for any help
3 Answers

Bernie Deitrick

5/12/2009 4:15:00 PM

0

Pawpaw,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column <> 2 And Target.Column <> 7 Then Exit Sub
Application.EnableEvents = False
Cells(Target.Row, IIf(Target.Column = 2, 26, 27)).Value = _
Cells(Target.Row, IIf(Target.Column = 2, 26, 27)).Value + 1
Application.EnableEvents = True
End Sub

HTH,
Bernie
MS Excel MVP


"Pawpaw" <Pawpaw@discussions.microsoft.com> wrote in message
news:C27D7BEC-CFFF-4196-ADD2-E73654DF824E@microsoft.com...
> Thank you so much Mr. Deitrick, it worked perfectly.
>
> I hate to bother you again. You are probably very busy so I will
> understand if you do not have the time. I neglected to mention that I also do
> the same thing with columns F, G. and H. In column F is a number. In column G
> he has to type a number. In column H is the formula "=a1/a2" If he types the
> correct number in column G the correct answer will appear in column H. I also
> have the correct answer listed in column I. His instructions are to type the
> correct number in column G and if he does then the answer in
> column H will match the number in column I.
> Now what I would like to do is to be able to have a column that counts
> the number of times he types a number in column G so that I will know that he
> is actually doing the work and not just guessing by typing numbers in column
> G until he gets the correct answer.
> Mr. Deitrick if you could write another formula just like the one you
> wrote earlier that placed the answer in column Z, but this time have the
> answer placed in column AA or if you could explain to me the formula I would
> be able to write it myself. Either way I will appreciate whatever you can do.
> Thank you again for your time.
>
> "Bernie Deitrick" wrote:
>
>> Pawpaw,
>>
>> Copy the code below, right-click the sheet tab, select "View Code" and paste
>> the code into the window that appears. The code will count the number of
>> tries in column B, recording the number in column Z of the same row, out of
>> sight and so, perhaps, un-noticed by your grandson. The second version (you
>> can only use one) will record his entered values starting in column AA and
>> on to the right, so that you can see what he did in each cell.
>>
>> HTH,
>> Bernie
>> MS Excel MVP
>>
>> Private Sub Worksheet_Change(ByVal Target As Range)
>> If Target.Cells.Count > 1 Then Exit Sub
>> If Target.Column <> 2 Then Exit Sub
>> Application.EnableEvents = False
>> Cells(Target.Row, 26).Value = Cells(Target.Row, 26).Value + 1
>> Application.EnableEvents = True
>> End Sub
>>
>>
>> Private Sub Worksheet_Change(ByVal Target As Range)
>> If Target.Cells.Count > 1 Then Exit Sub
>> If Target.Column <> 2 Then Exit Sub
>> Application.EnableEvents = False
>> Cells(Target.Row, 26).Value = Cells(Target.Row, 26).Value + 1
>> Cells(Target.Row, Columns.Count).End(xlToLeft).Cells(1,2).Value =
>> Target.Value
>> Application.EnableEvents = True
>> End Sub
>>
>> "Pawpaw" <Pawpaw@discussions.microsoft.com> wrote in message
>> news:07EEA818-B580-4C2F-8551-D7CE2C4CE9AA@microsoft.com...
>> > I use Excel to teach my grandson math. In column A is a number. In
>> > column B he has to type a number. In column C is the formula "=a1/a2" If
>> > he
>> > types the correct number in column B the correct answer will appear in
>> > column
>> > C. I also have the correct answer listed in column D. His instructions are
>> > to
>> > type the correct number in column B and if he does then the answer in
>> > column
>> > C will match the number in column D.
>> > Now what I would like to do is to be able to have a column that counts
>> > the number of times he types a number in column B so that I will know that
>> > he
>> > is actually doing the work and not just guessing by typing numbers in
>> > column
>> > B until he gets the correct answer.
>>
>>


Pawpaw

5/12/2009 6:34:00 PM

0

Thank you so much Mr. Deitrick it worked perfectly.

"Bernie Deitrick" wrote:

> Pawpaw,
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Cells.Count > 1 Then Exit Sub
> If Target.Column <> 2 And Target.Column <> 7 Then Exit Sub
> Application.EnableEvents = False
> Cells(Target.Row, IIf(Target.Column = 2, 26, 27)).Value = _
> Cells(Target.Row, IIf(Target.Column = 2, 26, 27)).Value + 1
> Application.EnableEvents = True
> End Sub
>
> HTH,
> Bernie
> MS Excel MVP
>
>
> "Pawpaw" <Pawpaw@discussions.microsoft.com> wrote in message
> news:C27D7BEC-CFFF-4196-ADD2-E73654DF824E@microsoft.com...
> > Thank you so much Mr. Deitrick, it worked perfectly.
> >
> > I hate to bother you again. You are probably very busy so I will
> > understand if you do not have the time. I neglected to mention that I also do
> > the same thing with columns F, G. and H. In column F is a number. In column G
> > he has to type a number. In column H is the formula "=a1/a2" If he types the
> > correct number in column G the correct answer will appear in column H. I also
> > have the correct answer listed in column I. His instructions are to type the
> > correct number in column G and if he does then the answer in
> > column H will match the number in column I.
> > Now what I would like to do is to be able to have a column that counts
> > the number of times he types a number in column G so that I will know that he
> > is actually doing the work and not just guessing by typing numbers in column
> > G until he gets the correct answer.
> > Mr. Deitrick if you could write another formula just like the one you
> > wrote earlier that placed the answer in column Z, but this time have the
> > answer placed in column AA or if you could explain to me the formula I would
> > be able to write it myself. Either way I will appreciate whatever you can do.
> > Thank you again for your time.
> >
> > "Bernie Deitrick" wrote:
> >
> >> Pawpaw,
> >>
> >> Copy the code below, right-click the sheet tab, select "View Code" and paste
> >> the code into the window that appears. The code will count the number of
> >> tries in column B, recording the number in column Z of the same row, out of
> >> sight and so, perhaps, un-noticed by your grandson. The second version (you
> >> can only use one) will record his entered values starting in column AA and
> >> on to the right, so that you can see what he did in each cell.
> >>
> >> HTH,
> >> Bernie
> >> MS Excel MVP
> >>
> >> Private Sub Worksheet_Change(ByVal Target As Range)
> >> If Target.Cells.Count > 1 Then Exit Sub
> >> If Target.Column <> 2 Then Exit Sub
> >> Application.EnableEvents = False
> >> Cells(Target.Row, 26).Value = Cells(Target.Row, 26).Value + 1
> >> Application.EnableEvents = True
> >> End Sub
> >>
> >>
> >> Private Sub Worksheet_Change(ByVal Target As Range)
> >> If Target.Cells.Count > 1 Then Exit Sub
> >> If Target.Column <> 2 Then Exit Sub
> >> Application.EnableEvents = False
> >> Cells(Target.Row, 26).Value = Cells(Target.Row, 26).Value + 1
> >> Cells(Target.Row, Columns.Count).End(xlToLeft).Cells(1,2).Value =
> >> Target.Value
> >> Application.EnableEvents = True
> >> End Sub
> >>
> >> "Pawpaw" <Pawpaw@discussions.microsoft.com> wrote in message
> >> news:07EEA818-B580-4C2F-8551-D7CE2C4CE9AA@microsoft.com...
> >> > I use Excel to teach my grandson math. In column A is a number. In
> >> > column B he has to type a number. In column C is the formula "=a1/a2" If
> >> > he
> >> > types the correct number in column B the correct answer will appear in
> >> > column
> >> > C. I also have the correct answer listed in column D. His instructions are
> >> > to
> >> > type the correct number in column B and if he does then the answer in
> >> > column
> >> > C will match the number in column D.
> >> > Now what I would like to do is to be able to have a column that counts
> >> > the number of times he types a number in column B so that I will know that
> >> > he
> >> > is actually doing the work and not just guessing by typing numbers in
> >> > column
> >> > B until he gets the correct answer.
> >>
> >>
>
>
>

Bernie Deitrick

5/12/2009 6:42:00 PM

0

You're very welcome. Good luck with your grandson.

Bernie
MS Excel MVP


"Pawpaw" <Pawpaw@discussions.microsoft.com> wrote in message
news:458D0EAE-C685-4DD8-86F2-D7A4FBC3F3B0@microsoft.com...
> Thank you so much Mr. Deitrick it worked perfectly.
>