LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default count where item =x

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
 
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
Item Count Kam Excel Programming 4 January 2nd 08 01:32 PM
how to count specific item??? Jeff32 Excel Discussion (Misc queries) 2 May 7th 06 05:38 PM
to How to use Excel formula to count the item annsmjarm Excel Discussion (Misc queries) 1 September 14th 05 12:35 PM
count of item in excel workshop Ronald Dodge Excel Programming 0 August 29th 03 08:49 PM
count of item in excel workshop Tom Ogilvy Excel Programming 0 August 29th 03 08:45 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"