PC Review


Reply
Thread Tools Rate Thread

Counter for user clicks

 
 
=?Utf-8?B?QW50aG9ueQ==?=
Guest
Posts: n/a
 
      5th Mar 2007
Can anybody provide some code for the following ..

Basically, the user is playing a game which consists of 21 rounds - after
the first 4 rounds they are forced to 'gamble' (and taken sheet4) after the
next 3 and every 3 thereafter they are again forced to 'gamble' until there
are just two rounds left. At this point the game ends and sheet6 is opened

So what I really need is a 'counter' which starts at 21 and each time the
user clciks a cell on sheet1 the counter reduces by 1. When this counter
reaches either 18,15,11,8,4,2 it firstly reduces the counter by 1 then runs
the 'banker' macro.

I hope I have explained this well and hope even more it can be done!
many thanks in advance
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      5th Mar 2007
Here's one way, using the ThisWorkbook module. However, your description and
example do not seem to match ??

Dim ClickCount As Long
Private Const STARTCLICKCOUNT As Long = 21

Private Sub Workbook_Open()
ClickCount = STARTCLICKCOUNT
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
ClickCount = ClickCount - 1

Select Case ClickCount
Case 18, 15, 11, 8, 4, 2
Call Banker(Sh, Target)
Case Else
'Do Nothing ?
End Select

End Sub

Private Function Banker(WhichSheet As Worksheet, WhichCell As Range) As Long
MsgBox "Cell '" & WhichCell.Address & "' clicked on sheet '" &
WhichSheet.Name & "'"
End Function

NickHK

"Anthony" <(E-Mail Removed)> wrote in message
news:943F6131-EBFD-40AE-94BA-(E-Mail Removed)...
> Can anybody provide some code for the following ..
>
> Basically, the user is playing a game which consists of 21 rounds - after
> the first 4 rounds they are forced to 'gamble' (and taken sheet4) after

the
> next 3 and every 3 thereafter they are again forced to 'gamble' until

there
> are just two rounds left. At this point the game ends and sheet6 is opened
>
> So what I really need is a 'counter' which starts at 21 and each time the
> user clciks a cell on sheet1 the counter reduces by 1. When this counter
> reaches either 18,15,11,8,4,2 it firstly reduces the counter by 1 then

runs
> the 'banker' macro.
>
> I hope I have explained this well and hope even more it can be done!
> many thanks in advance



 
Reply With Quote
 
=?Utf-8?B?QW50aG9ueQ==?=
Guest
Posts: n/a
 
      5th Mar 2007
Nick,
thanks for ur help,
before | can try ur code, I have pasted it into the vb explorer and this
part is highlighted in red, ie an error and as my knowledge isn't too good on
vb I don't know what is wrong, can you check it out for me..

the bit highlighted in red is...

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object ByVal Target As
Range)

thanks

"NickHK" wrote:

> Here's one way, using the ThisWorkbook module. However, your description and
> example do not seem to match ??
>
> Dim ClickCount As Long
> Private Const STARTCLICKCOUNT As Long = 21
>
> Private Sub Workbook_Open()
> ClickCount = STARTCLICKCOUNT
> End Sub
>
> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
> As Range)
> ClickCount = ClickCount - 1
>
> Select Case ClickCount
> Case 18, 15, 11, 8, 4, 2
> Call Banker(Sh, Target)
> Case Else
> 'Do Nothing ?
> End Select
>
> End Sub
>
> Private Function Banker(WhichSheet As Worksheet, WhichCell As Range) As Long
> MsgBox "Cell '" & WhichCell.Address & "' clicked on sheet '" &
> WhichSheet.Name & "'"
> End Function
>
> NickHK
>
> "Anthony" <(E-Mail Removed)> wrote in message
> news:943F6131-EBFD-40AE-94BA-(E-Mail Removed)...
> > Can anybody provide some code for the following ..
> >
> > Basically, the user is playing a game which consists of 21 rounds - after
> > the first 4 rounds they are forced to 'gamble' (and taken sheet4) after

> the
> > next 3 and every 3 thereafter they are again forced to 'gamble' until

> there
> > are just two rounds left. At this point the game ends and sheet6 is opened
> >
> > So what I really need is a 'counter' which starts at 21 and each time the
> > user clciks a cell on sheet1 the counter reduces by 1. When this counter
> > reaches either 18,15,11,8,4,2 it firstly reduces the counter by 1 then

> runs
> > the 'banker' macro.
> >
> > I hope I have explained this well and hope even more it can be done!
> > many thanks in advance

>
>
>

 
Reply With Quote
 
Jean-Yves
Guest
Posts: n/a
 
      5th Mar 2007
Put it back on one line : Private Sub Workbook_SheetSelectionChange(ByVal Sh
As Object ByVal Target As Range)
or Alternatively, for reading purposes, you can split using the underscore
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object ByVal Target
As _
Range)
HTH
Regards
JY

"Anthony" <(E-Mail Removed)> wrote in message
news:50458AC4-3A7C-4E2D-BFB8-(E-Mail Removed)...
> Nick,
> thanks for ur help,
> before | can try ur code, I have pasted it into the vb explorer and this
> part is highlighted in red, ie an error and as my knowledge isn't too good
> on
> vb I don't know what is wrong, can you check it out for me..
>
> the bit highlighted in red is...
>
> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object ByVal Target
> As
> Range)
>
> thanks
>
> "NickHK" wrote:
>
>> Here's one way, using the ThisWorkbook module. However, your description
>> and
>> example do not seem to match ??
>>
>> Dim ClickCount As Long
>> Private Const STARTCLICKCOUNT As Long = 21
>>
>> Private Sub Workbook_Open()
>> ClickCount = STARTCLICKCOUNT
>> End Sub
>>
>> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
>> Target
>> As Range)
>> ClickCount = ClickCount - 1
>>
>> Select Case ClickCount
>> Case 18, 15, 11, 8, 4, 2
>> Call Banker(Sh, Target)
>> Case Else
>> 'Do Nothing ?
>> End Select
>>
>> End Sub
>>
>> Private Function Banker(WhichSheet As Worksheet, WhichCell As Range) As
>> Long
>> MsgBox "Cell '" & WhichCell.Address & "' clicked on sheet '" &
>> WhichSheet.Name & "'"
>> End Function
>>
>> NickHK
>>
>> "Anthony" <(E-Mail Removed)> wrote in message
>> news:943F6131-EBFD-40AE-94BA-(E-Mail Removed)...
>> > Can anybody provide some code for the following ..
>> >
>> > Basically, the user is playing a game which consists of 21 rounds -
>> > after
>> > the first 4 rounds they are forced to 'gamble' (and taken sheet4) after

>> the
>> > next 3 and every 3 thereafter they are again forced to 'gamble' until

>> there
>> > are just two rounds left. At this point the game ends and sheet6 is
>> > opened
>> >
>> > So what I really need is a 'counter' which starts at 21 and each time
>> > the
>> > user clciks a cell on sheet1 the counter reduces by 1. When this
>> > counter
>> > reaches either 18,15,11,8,4,2 it firstly reduces the counter by 1 then

>> runs
>> > the 'banker' macro.
>> >
>> > I hope I have explained this well and hope even more it can be done!
>> > many thanks in advance

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?QW50aG9ueQ==?=
Guest
Posts: n/a
 
      5th Mar 2007
Hi,
thanks for your suggestions, however both still return the code with an
error by highlighting it in red,
the content must have someting missing?
can you see if you can find it?
thanks

"Jean-Yves" wrote:

> Put it back on one line : Private Sub Workbook_SheetSelectionChange(ByVal Sh
> As Object ByVal Target As Range)
> or Alternatively, for reading purposes, you can split using the underscore
> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object ByVal Target
> As _
> Range)
> HTH
> Regards
> JY
>
> "Anthony" <(E-Mail Removed)> wrote in message
> news:50458AC4-3A7C-4E2D-BFB8-(E-Mail Removed)...
> > Nick,
> > thanks for ur help,
> > before | can try ur code, I have pasted it into the vb explorer and this
> > part is highlighted in red, ie an error and as my knowledge isn't too good
> > on
> > vb I don't know what is wrong, can you check it out for me..
> >
> > the bit highlighted in red is...
> >
> > Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object ByVal Target
> > As
> > Range)
> >
> > thanks
> >
> > "NickHK" wrote:
> >
> >> Here's one way, using the ThisWorkbook module. However, your description
> >> and
> >> example do not seem to match ??
> >>
> >> Dim ClickCount As Long
> >> Private Const STARTCLICKCOUNT As Long = 21
> >>
> >> Private Sub Workbook_Open()
> >> ClickCount = STARTCLICKCOUNT
> >> End Sub
> >>
> >> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
> >> Target
> >> As Range)
> >> ClickCount = ClickCount - 1
> >>
> >> Select Case ClickCount
> >> Case 18, 15, 11, 8, 4, 2
> >> Call Banker(Sh, Target)
> >> Case Else
> >> 'Do Nothing ?
> >> End Select
> >>
> >> End Sub
> >>
> >> Private Function Banker(WhichSheet As Worksheet, WhichCell As Range) As
> >> Long
> >> MsgBox "Cell '" & WhichCell.Address & "' clicked on sheet '" &
> >> WhichSheet.Name & "'"
> >> End Function
> >>
> >> NickHK
> >>
> >> "Anthony" <(E-Mail Removed)> wrote in message
> >> news:943F6131-EBFD-40AE-94BA-(E-Mail Removed)...
> >> > Can anybody provide some code for the following ..
> >> >
> >> > Basically, the user is playing a game which consists of 21 rounds -
> >> > after
> >> > the first 4 rounds they are forced to 'gamble' (and taken sheet4) after
> >> the
> >> > next 3 and every 3 thereafter they are again forced to 'gamble' until
> >> there
> >> > are just two rounds left. At this point the game ends and sheet6 is
> >> > opened
> >> >
> >> > So what I really need is a 'counter' which starts at 21 and each time
> >> > the
> >> > user clciks a cell on sheet1 the counter reduces by 1. When this
> >> > counter
> >> > reaches either 18,15,11,8,4,2 it firstly reduces the counter by 1 then
> >> runs
> >> > the 'banker' macro.
> >> >
> >> > I hope I have explained this well and hope even more it can be done!
> >> > many thanks in advance
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Jean-Yves
Guest
Posts: n/a
 
      5th Mar 2007
There is a comma missing
Private Sub Workbook_SheetSelectionChange(ByVal Sh , As Object
ByVal Target As Range)
The proper way to create such a macro name is to go to the project exp,orer
Double-click on the ThisWorkbook module
In the window part left top, you should see a dropdown reading General.
Select there Workbook instead.
In the window part righttop, you should see another dropdown reading
Declaration or Open now as you have selected the workbook events just
before.
Select here now Workbook_SheetSelectionChange
all this events are preprogrammed and the code that will be inserted will be
executed/fired when the event takes place.
Standard events often used are Open , Close, before print, before save , etc

HTH
Regards.
JY

"Anthony" <(E-Mail Removed)> wrote in message
news:99E4E7C4-7DCB-4E34-83A3-(E-Mail Removed)...
> Hi,
> thanks for your suggestions, however both still return the code with an
> error by highlighting it in red,
> the content must have someting missing?
> can you see if you can find it?
> thanks
>
> "Jean-Yves" wrote:
>
>> Put it back on one line : Private Sub Workbook_SheetSelectionChange(ByVal
>> Sh
>> As Object ByVal Target As Range)
>> or Alternatively, for reading purposes, you can split using the
>> underscore
>> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object ByVal
>> Target
>> As _
>> Range)
>> HTH
>> Regards
>> JY
>>
>> "Anthony" <(E-Mail Removed)> wrote in message
>> news:50458AC4-3A7C-4E2D-BFB8-(E-Mail Removed)...
>> > Nick,
>> > thanks for ur help,
>> > before | can try ur code, I have pasted it into the vb explorer and
>> > this
>> > part is highlighted in red, ie an error and as my knowledge isn't too
>> > good
>> > on
>> > vb I don't know what is wrong, can you check it out for me..
>> >
>> > the bit highlighted in red is...
>> >
>> > Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object ByVal
>> > Target
>> > As
>> > Range)
>> >
>> > thanks
>> >
>> > "NickHK" wrote:
>> >
>> >> Here's one way, using the ThisWorkbook module. However, your
>> >> description
>> >> and
>> >> example do not seem to match ??
>> >>
>> >> Dim ClickCount As Long
>> >> Private Const STARTCLICKCOUNT As Long = 21
>> >>
>> >> Private Sub Workbook_Open()
>> >> ClickCount = STARTCLICKCOUNT
>> >> End Sub
>> >>
>> >> Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
>> >> Target
>> >> As Range)
>> >> ClickCount = ClickCount - 1
>> >>
>> >> Select Case ClickCount
>> >> Case 18, 15, 11, 8, 4, 2
>> >> Call Banker(Sh, Target)
>> >> Case Else
>> >> 'Do Nothing ?
>> >> End Select
>> >>
>> >> End Sub
>> >>
>> >> Private Function Banker(WhichSheet As Worksheet, WhichCell As Range)
>> >> As
>> >> Long
>> >> MsgBox "Cell '" & WhichCell.Address & "' clicked on sheet '" &
>> >> WhichSheet.Name & "'"
>> >> End Function
>> >>
>> >> NickHK
>> >>
>> >> "Anthony" <(E-Mail Removed)> wrote in message
>> >> news:943F6131-EBFD-40AE-94BA-(E-Mail Removed)...
>> >> > Can anybody provide some code for the following ..
>> >> >
>> >> > Basically, the user is playing a game which consists of 21 rounds -
>> >> > after
>> >> > the first 4 rounds they are forced to 'gamble' (and taken sheet4)
>> >> > after
>> >> the
>> >> > next 3 and every 3 thereafter they are again forced to 'gamble'
>> >> > until
>> >> there
>> >> > are just two rounds left. At this point the game ends and sheet6 is
>> >> > opened
>> >> >
>> >> > So what I really need is a 'counter' which starts at 21 and each
>> >> > time
>> >> > the
>> >> > user clciks a cell on sheet1 the counter reduces by 1. When this
>> >> > counter
>> >> > reaches either 18,15,11,8,4,2 it firstly reduces the counter by 1
>> >> > then
>> >> runs
>> >> > the 'banker' macro.
>> >> >
>> >> > I hope I have explained this well and hope even more it can be done!
>> >> > many thanks in advance
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
confirmation window once user clicks submit on user from sam Microsoft Excel Programming 4 7th Jul 2009 06:02 PM
User clicks vs address bar entry meendar Windows XP Internet Explorer 1 28th Aug 2007 10:45 PM
Limiting User Clicks Elroyskimms Microsoft ASP .NET 4 4th Jun 2005 08:40 PM
Get value in first column when user clicks on row Krish Microsoft C# .NET 1 15th Sep 2004 11:23 PM
Show user defined commandbarButton when the user right clicks on Contact Venugopal Microsoft Outlook Program Addins 3 19th Nov 2003 12:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:41 PM.