Okay, you didn't answer my "are the variables or are the controls" question
directly, but it looks like they are controls. You can reference a control
on a UserForm using the Me.Controls collection. For example, assuming MS is
a control where a value is typed or selected, this line which you
attempted...
If (CourseHandicap - "MS" & s) <= 0 Then Shots = 0
would be written this way...
If (CoursHandicap - Me.Controls("MS" & s).Value) <= 0 Then Shots = 0
So, for controls, where you are attempting to write this...
ControlName & Variable
use this instead....
Me.Controls(ControlName & Variable)
and I think you should always specify a property rather than relying on the
default property to be supplied by
VB when you omit specifying one.
Rick
"Blobbies" wrote in message
...
Hi Rick
Thanks for your time! Right - I have bitten the bullet and posted all the
code - I know that it will be very raw and entirely without order and
won't
follow rules etc, but I can usually bumble my way through!
It is a procedure to work out stableford points in golf!
See what you think!
Private Sub CommandButton5_Click()
Application.ScreenUpdating = False
Worksheets("Players").Select
Worksheets("Players").Unprotect
Range("A1").Select
With ActiveCell.EntireColumn
.Find(cbxPlayerName).Select
End With
Dim Shots As Integer
Set CourseHandicap = Cells(ActiveCell.Row, ActiveCell.Column + 4)
Set ScoringSex = Cells(ActiveCell.Row, ActiveCell.Column + 1)
For s = 1 To 18
If ScoringSex = "M" Then GoTo MEN
If ScoringSex = "F" Then GoTo WOMEN
MEN:
If (CourseHandicap - "MS" & s) <= 0 Then Shots = 0
If (CourseHandicap - "MS" & s) = 1 And (CourseHandicap - 10) <= 18 Then
Shots = 1
If (CourseHandicap - "MS" & s) 18 And (CourseHandicap - 10) <= 36 Then
Shots = 2
If (CourseHandicap - "MS" & s) 36 Then Shots = 3
If ScoringSex = M Then GoTo MISSTHEWOMEN
WOMEN:
If (CourseHandicap - "WS" & s) <= 0 Then Shots = 0
If (CourseHandicap - "WS" & s) = 1 And (CourseHandicap - 10) <= 18 Then
Shots = 1
If (CourseHandicap - "WS" & s) 18 And (CourseHandicap - 10) <= 36 Then
Shots = 2
If (CourseHandicap - "WS" & s) 36 Then Shots = 3
MISSTHEWOMEN:
If "MP" & s = 5 And Shots = 0 And "cbxHole" & s - "MP" & s = -4 Then
"Stable"&s = 6
If "MP" & s = 5 And Shots = 0 And "cbxHole" & s - "MP" & s = -3 Then
"Stable"&s = 5
If "MP" & s = 5 And Shots = 0 And "cbxHole" & s - "MP" & s = -2 Then
"Stable"&s = 4
If "MP" & s = 5 And Shots = 0 And "cbxHole" & s - "MP" & s = -1 Then
"Stable"&s = 3
If "MP" & s = 5 And Shots = 0 And "cbxHole" & s - "MP" & s = 0 Then
"Stable"&s = 2
If "MP" & s = 5 And Shots = 0 And "cbxHole" & s - "MP" & s = 1 Then
"Stable"&s = 1
Next s
End Sub
This procedure strikes problems at the "Then "Stable"&s =" part!
MP(Men's Par or WP women's par) is the par score for the holes (1-18) and
MS
or WS is the Men's/Women's stroke hole figure, which are both required to
work out the stableford points.
The course handicap comes from adetails sheet and is particular to each
player
MP/WP are assigned when the (enter the scores) userform is initiated, as
are
the MS/WS.
cbxHole1 - cbxHole18 are entered into the userform, depending on the
player's scores for the hole!
Thanks for your efforts!!
"Rick Rothstein (MVP - VB)" wrote:
What are Name1, Name2, etc.... variables or control names? If control
names,
what kind and where are they located... the worksheet or a UserForm?
Rick
"Blobbies" wrote in message
...
Hi there!
I really do just bumble my way through this stuff, so I apologise for
my
lack of technical know-how!
I want a procedure (set within a "for .... next") that says: if (a
happens)
and (b happens) and (c happens) then "Name" & s = (a number, i.e. 5 or
6
or 7
etc)
I'm trying to do it like this so I really don't have to post my actual
code!
I think the problem lies in the ("Name" & s) area!? It will work and
give
simply "Name" a value, but I need values for Name1, Name2, Name3 etc
Hopefully you guys can help without me having to embarrass myself with
posting code!?
Mike