PC Review


Reply
Thread Tools Rate Thread

count where item =x

 
 
alvin Kuiper
Guest
Posts: n/a
 
      11th May 2009
Hi
If i have 10 text boxe like txt_ci1 - txt_ci2 and so on

Is there a way to count all them where there are a X in

Regards

alvin
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      11th May 2009
Where are the TextBox'es located at... a VB UserForm or directly on a
worksheet? If on a worksheet, where did you get the TextBox'es from... the
Forms toolbar or the Drawing toolbar? Also, are these (going to be) the only
TextBox'es you have? If not, do the names for the 10 TextBox'es you are
interest in all start with "txt_ci" and, if so, are there any other
TextBox'es starting with those letters?

--
Rick (MVP - Excel)


"alvin Kuiper" <(E-Mail Removed)> wrote in message
news:F7D736BC-FDE8-4691-981B-(E-Mail Removed)...
> Hi
> If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
>
> Is there a way to count all them where there are a X in
>
> Regards
>
> alvin


 
Reply With Quote
 
alvin Kuiper
Guest
Posts: n/a
 
      11th May 2009
Teh are in a userform
and are hand made

Alvin


"Rick Rothstein" skrev:

> Where are the TextBox'es located at... a VB UserForm or directly on a
> worksheet? If on a worksheet, where did you get the TextBox'es from... the
> Forms toolbar or the Drawing toolbar? Also, are these (going to be) the only
> TextBox'es you have? If not, do the names for the 10 TextBox'es you are
> interest in all start with "txt_ci" and, if so, are there any other
> TextBox'es starting with those letters?
>
> --
> Rick (MVP - Excel)
>
>
> "alvin Kuiper" <(E-Mail Removed)> wrote in message
> news:F7D736BC-FDE8-4691-981B-(E-Mail Removed)...
> > Hi
> > If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
> >
> > Is there a way to count all them where there are a X in
> >
> > Regards
> >
> > alvin

>
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      11th May 2009
"hand made" didn't really answer these questions...

"Also, are these (going to be) the only TextBox'es you have?
If not, do the names for the 10 TextBox'es you are interest
in all start with "txt_ci" and, if so, are there any other TextBox'es
starting with those letters?"

--
Rick (MVP - Excel)


"alvin Kuiper" <(E-Mail Removed)> wrote in message
news:E9F0D142-DAD7-43F9-ACDA-(E-Mail Removed)...
> Teh are in a userform
> and are hand made
>
> Alvin
>
>
> "Rick Rothstein" skrev:
>
>> Where are the TextBox'es located at... a VB UserForm or directly on a
>> worksheet? If on a worksheet, where did you get the TextBox'es from...
>> the
>> Forms toolbar or the Drawing toolbar? Also, are these (going to be) the
>> only
>> TextBox'es you have? If not, do the names for the 10 TextBox'es you are
>> interest in all start with "txt_ci" and, if so, are there any other
>> TextBox'es starting with those letters?
>>
>> --
>> Rick (MVP - Excel)
>>
>>
>> "alvin Kuiper" <(E-Mail Removed)> wrote in message
>> news:F7D736BC-FDE8-4691-981B-(E-Mail Removed)...
>> > Hi
>> > If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
>> >
>> > Is there a way to count all them where there are a X in
>> >
>> > Regards
>> >
>> > alvin

>>
>>


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th May 2009
As long as you named them nice, you can just loop through them:

Option Explicit
Private Sub CommandButton1_Click()
Dim iCtr As Long
Dim MaxTBX As Long
Dim TotTBX As Long

MaxTBX = 3 '10 for you

TotTBX = 0
For iCtr = 1 To MaxTBX
If LCase(Me.Controls("txt_ci" & iCtr).Value) = "x" Then
TotTBX = TotTBX + 1
End If
Next iCtr

MsgBox TotTBX

End Sub

But if you're looking for an X (some kind of indicator???), maybe using 10
checkboxes would be better. Less chance of typing errors????



alvin Kuiper wrote:
>
> Hi
> If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
>
> Is there a way to count all them where there are a X in
>
> Regards
>
> alvin


--

Dave Peterson
 
Reply With Quote
 
alvin Kuiper
Guest
Posts: n/a
 
      12th May 2009
Hi
And thanks , it works
But now if i want to make a check box instead of the text field
cam you help me there.

alvin


"Dave Peterson" skrev:

> As long as you named them nice, you can just loop through them:
>
> Option Explicit
> Private Sub CommandButton1_Click()
> Dim iCtr As Long
> Dim MaxTBX As Long
> Dim TotTBX As Long
>
> MaxTBX = 3 '10 for you
>
> TotTBX = 0
> For iCtr = 1 To MaxTBX
> If LCase(Me.Controls("txt_ci" & iCtr).Value) = "x" Then
> TotTBX = TotTBX + 1
> End If
> Next iCtr
>
> MsgBox TotTBX
>
> End Sub
>
> But if you're looking for an X (some kind of indicator???), maybe using 10
> checkboxes would be better. Less chance of typing errors????
>
>
>
> alvin Kuiper wrote:
> >
> > Hi
> > If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
> >
> > Is there a way to count all them where there are a X in
> >
> > Regards
> >
> > alvin

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      12th May 2009
It's pretty much the same--if you name them nicely:

Option Explicit
Private Sub CommandButton1_Click()
Dim iCtr As Long
Dim MaxCBX As Long
Dim TotCBX As Long

MaxCBX = 3 '10 for you

TotCBX = 0
For iCtr = 1 To MaxCBX
If LCase(Me.Controls("CBX_ci" & iCtr).Value) = True Then
TotCBX = TotCBX + 1
End If
Next iCtr

MsgBox TotCBX

End Sub



alvin Kuiper wrote:
>
> Hi
> And thanks , it works
> But now if i want to make a check box instead of the text field
> cam you help me there.
>
> alvin
>
> "Dave Peterson" skrev:
>
> > As long as you named them nice, you can just loop through them:
> >
> > Option Explicit
> > Private Sub CommandButton1_Click()
> > Dim iCtr As Long
> > Dim MaxTBX As Long
> > Dim TotTBX As Long
> >
> > MaxTBX = 3 '10 for you
> >
> > TotTBX = 0
> > For iCtr = 1 To MaxTBX
> > If LCase(Me.Controls("txt_ci" & iCtr).Value) = "x" Then
> > TotTBX = TotTBX + 1
> > End If
> > Next iCtr
> >
> > MsgBox TotTBX
> >
> > End Sub
> >
> > But if you're looking for an X (some kind of indicator???), maybe using 10
> > checkboxes would be better. Less chance of typing errors????
> >
> >
> >
> > alvin Kuiper wrote:
> > >
> > > Hi
> > > If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
> > >
> > > Is there a way to count all them where there are a X in
> > >
> > > Regards
> > >
> > > alvin

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
alvin Kuiper
Guest
Posts: n/a
 
      13th May 2009
Yes
this work
but again why don't it work in a modul
but only on the button
My button are in a multipage in a userform

If i try to run it from the modul i get a error in:
ME
in the line:
If LCase(Me.Controls("CBX_ci" & iCtr).Value) = True Then

alvin

"Dave Peterson" skrev:

> It's pretty much the same--if you name them nicely:
>
> Option Explicit
> Private Sub CommandButton1_Click()
> Dim iCtr As Long
> Dim MaxCBX As Long
> Dim TotCBX As Long
>
> MaxCBX = 3 '10 for you
>
> TotCBX = 0
> For iCtr = 1 To MaxCBX
> If LCase(Me.Controls("CBX_ci" & iCtr).Value) = True Then
> TotCBX = TotCBX + 1
> End If
> Next iCtr
>
> MsgBox TotCBX
>
> End Sub
>
>
>
> alvin Kuiper wrote:
> >
> > Hi
> > And thanks , it works
> > But now if i want to make a check box instead of the text field
> > cam you help me there.
> >
> > alvin
> >
> > "Dave Peterson" skrev:
> >
> > > As long as you named them nice, you can just loop through them:
> > >
> > > Option Explicit
> > > Private Sub CommandButton1_Click()
> > > Dim iCtr As Long
> > > Dim MaxTBX As Long
> > > Dim TotTBX As Long
> > >
> > > MaxTBX = 3 '10 for you
> > >
> > > TotTBX = 0
> > > For iCtr = 1 To MaxTBX
> > > If LCase(Me.Controls("txt_ci" & iCtr).Value) = "x" Then
> > > TotTBX = TotTBX + 1
> > > End If
> > > Next iCtr
> > >
> > > MsgBox TotTBX
> > >
> > > End Sub
> > >
> > > But if you're looking for an X (some kind of indicator???), maybe using 10
> > > checkboxes would be better. Less chance of typing errors????
> > >
> > >
> > >
> > > alvin Kuiper wrote:
> > > >
> > > > Hi
> > > > If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
> > > >
> > > > Is there a way to count all them where there are a X in
> > > >
> > > > Regards
> > > >
> > > > alvin
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      13th May 2009
Me is the object that owns the code--in my example, it's the userform.

If you have the code in a general module, then try:
if lcase(userform1.controls("cbx_ci" & ....

(use the name of the userform that you're using (and that's loaded at the
time).)



alvin Kuiper wrote:
>
> Yes
> this work
> but again why don't it work in a modul
> but only on the button
> My button are in a multipage in a userform
>
> If i try to run it from the modul i get a error in:
> ME
> in the line:
> If LCase(Me.Controls("CBX_ci" & iCtr).Value) = True Then
>
> alvin
>
> "Dave Peterson" skrev:
>
> > It's pretty much the same--if you name them nicely:
> >
> > Option Explicit
> > Private Sub CommandButton1_Click()
> > Dim iCtr As Long
> > Dim MaxCBX As Long
> > Dim TotCBX As Long
> >
> > MaxCBX = 3 '10 for you
> >
> > TotCBX = 0
> > For iCtr = 1 To MaxCBX
> > If LCase(Me.Controls("CBX_ci" & iCtr).Value) = True Then
> > TotCBX = TotCBX + 1
> > End If
> > Next iCtr
> >
> > MsgBox TotCBX
> >
> > End Sub
> >
> >
> >
> > alvin Kuiper wrote:
> > >
> > > Hi
> > > And thanks , it works
> > > But now if i want to make a check box instead of the text field
> > > cam you help me there.
> > >
> > > alvin
> > >
> > > "Dave Peterson" skrev:
> > >
> > > > As long as you named them nice, you can just loop through them:
> > > >
> > > > Option Explicit
> > > > Private Sub CommandButton1_Click()
> > > > Dim iCtr As Long
> > > > Dim MaxTBX As Long
> > > > Dim TotTBX As Long
> > > >
> > > > MaxTBX = 3 '10 for you
> > > >
> > > > TotTBX = 0
> > > > For iCtr = 1 To MaxTBX
> > > > If LCase(Me.Controls("txt_ci" & iCtr).Value) = "x" Then
> > > > TotTBX = TotTBX + 1
> > > > End If
> > > > Next iCtr
> > > >
> > > > MsgBox TotTBX
> > > >
> > > > End Sub
> > > >
> > > > But if you're looking for an X (some kind of indicator???), maybe using 10
> > > > checkboxes would be better. Less chance of typing errors????
> > > >
> > > >
> > > >
> > > > alvin Kuiper wrote:
> > > > >
> > > > > Hi
> > > > > If i have 10 text boxe like txt_ci1 - txt_ci2 and so on
> > > > >
> > > > > Is there a way to count all them where there are a X in
> > > > >
> > > > > Regards
> > > > >
> > > > > alvin
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
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
Item Count vs Item Cost Michael Koerner Microsoft Excel Programming 1 31st Oct 2009 09:16 AM
Item Count Kam Microsoft Excel Programming 4 2nd Jan 2008 01:32 PM
Item count =?Utf-8?B?VGhlIENhdHdvcmtzIENhdA==?= Microsoft Access 2 27th Jul 2007 07:58 PM
item count =?Utf-8?B?S2F0?= Microsoft Word Document Management 1 4th Dec 2004 07:57 PM
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added Praveen Balanagendra via .NET 247 Microsoft ASP .NET 2 6th Jun 2004 08:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:17 AM.