Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default check control names

I would like to be able to run a code that will check to see if a
control has a particular name and then tell me which one has that
name. I thought the code below would work but it does not do the
trick.

Private Sub btnSubmit_Click()

Dim C As Control
For Each C In Me.Controls
If C.Name = "txtnum1" Then
MsgBox C.Name
End If
Next C


End Sub

Additionally is there a way to use a wild card. For example show me
all textboxes that start with txtNum (txtNum1, txtNum2, etc)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default check control names

It worked ok for me.

Maybe you need:

if lcase(c.name) = "txtnum1" then



stewart wrote:

I would like to be able to run a code that will check to see if a
control has a particular name and then tell me which one has that
name. I thought the code below would work but it does not do the
trick.

Private Sub btnSubmit_Click()

Dim C As Control
For Each C In Me.Controls
If C.Name = "txtnum1" Then
MsgBox C.Name
End If
Next C

End Sub

Additionally is there a way to use a wild card. For example show me
all textboxes that start with txtNum (txtNum1, txtNum2, etc)


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default check control names

On Sep 13, 8:55 pm, Dave Peterson wrote:
It worked ok for me.

Maybe you need:

if lcase(c.name) = "txtnum1" then



stewart wrote:

I would like to be able to run a code that will check to see if a
control has a particular name and then tell me which one has that
name. I thought the code below would work but it does not do the
trick.


Private Sub btnSubmit_Click()


Dim C As Control
For Each C In Me.Controls
If C.Name = "txtnum1" Then
MsgBox C.Name
End If
Next C


End Sub


Additionally is there a way to use a wild card. For example show me
all textboxes that start with txtNum (txtNum1, txtNum2, etc)


--

Dave Peterson


that did the trick...now is there a way to change that so i can search
for a wildcard. i want to find all textboxes that begin with txtNum

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default check control names

One way is to just look at the leftmost 6 chars:

if left(lcase(c.name),6) = "txtnum" then



stewart wrote:

On Sep 13, 8:55 pm, Dave Peterson wrote:
It worked ok for me.

Maybe you need:

if lcase(c.name) = "txtnum1" then



stewart wrote:

I would like to be able to run a code that will check to see if a
control has a particular name and then tell me which one has that
name. I thought the code below would work but it does not do the
trick.


Private Sub btnSubmit_Click()


Dim C As Control
For Each C In Me.Controls
If C.Name = "txtnum1" Then
MsgBox C.Name
End If
Next C


End Sub


Additionally is there a way to use a wild card. For example show me
all textboxes that start with txtNum (txtNum1, txtNum2, etc)


--

Dave Peterson


that did the trick...now is there a way to change that so i can search
for a wildcard. i want to find all textboxes that begin with txtNum


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default check control names

On Sep 13, 9:38 pm, Dave Peterson wrote:
One way is to just look at the leftmost 6 chars:

if left(lcase(c.name),6) = "txtnum" then



stewart wrote:

On Sep 13, 8:55 pm, Dave Peterson wrote:
It worked ok for me.


Maybe you need:


if lcase(c.name) = "txtnum1" then


stewart wrote:


I would like to be able to run a code that will check to see if a
control has a particular name and then tell me which one has that
name. I thought the code below would work but it does not do the
trick.


Private Sub btnSubmit_Click()


Dim C As Control
For Each C In Me.Controls
If C.Name = "txtnum1" Then
MsgBox C.Name
End If
Next C


End Sub


Additionally is there a way to use a wild card. For example show me
all textboxes that start with txtNum (txtNum1, txtNum2, etc)


--


Dave Peterson


that did the trick...now is there a way to change that so i can search
for a wildcard. i want to find all textboxes that begin with txtNum


--

Dave Peterson


thank you

Reply
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
How do I add a control check box to control other checkboxes? JGarland Excel Worksheet Functions 1 September 18th 08 12:26 PM
Check Box Control Mr. Matt Excel Programming 2 April 20th 07 01:51 PM
Control Names Graham Y Excel Programming 2 October 10th 06 04:59 PM
Can I check names in one list agains names in another in excel? John@Hospice of Hope Excel Discussion (Misc queries) 1 August 22nd 06 09:24 AM
Check box control Robert Blankenship Excel Programming 2 April 28th 06 03:03 PM


All times are GMT +1. The time now is 09:35 PM.

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

About Us

"It's about Microsoft Excel"