Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Identifying Userform Control Type

Hi All
How can I identifiy the type of control (command button, testbox etc.) on a
userform?

I wish to do two things...

1. Store the control type in a sheet cell
2. Use a conditional depending on the control type

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Identifying Userform Control Type

Hi Nigel.
Something like the following code, when used in the code window behind
the userform, seems to work:

'=============================
Dim ctl As Control
dim i as integer

i=1

For Each ctl In Me.Controls

Activesheet.cells(i,1) = ctl.typeof 'this will list the type in
column1

if ctl.TypeOf ctl Is MSForms.textbox then
msgbox "Your textbox contains the following text " & ctl.text
end if

i=i+1

next ctl
'=============================

Hope this is a start for you
Rgds
J




Nigel RS wrote:

Hi All
How can I identifiy the type of control (command button, testbox etc.) on a
userform?

I wish to do two things...

1. Store the control type in a sheet cell
2. Use a conditional depending on the control type

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Identifying Userform Control Type

dim ctr as control
for each ctr in myform.controls
n = n + 1
sType = typename(ctr)
cells(n,1) = sType
cells(n,2) = ctr.name

select case sType
case "CommandButton": 'code
' etc
end select
next

(not tested)

Regards,
Peter T

"Nigel RS" wrote in message
...
Hi All
How can I identifiy the type of control (command button, testbox etc.) on

a
userform?

I wish to do two things...

1. Store the control type in a sheet cell
2. Use a conditional depending on the control type

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Identifying Userform Control Type

Hi

ctl.typeof - does not work but

TypeName(ctl) does.

Thanks for the pointer

"WhytheQ" wrote:

Hi Nigel.
Something like the following code, when used in the code window behind
the userform, seems to work:

'=============================
Dim ctl As Control
dim i as integer

i=1

For Each ctl In Me.Controls

Activesheet.cells(i,1) = ctl.typeof 'this will list the type in
column1

if ctl.TypeOf ctl Is MSForms.textbox then
msgbox "Your textbox contains the following text " & ctl.text
end if

i=i+1

next ctl
'=============================

Hope this is a start for you
Rgds
J




Nigel RS wrote:

Hi All
How can I identifiy the type of control (command button, testbox etc.) on a
userform?

I wish to do two things...

1. Store the control type in a sheet cell
2. Use a conditional depending on the control type

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Identifying Userform Control Type

Thank You

I used TypeName(ctr) as the assignment value

Cheers

"Peter T" wrote:

dim ctr as control
for each ctr in myform.controls
n = n + 1
sType = typename(ctr)
cells(n,1) = sType
cells(n,2) = ctr.name

select case sType
case "CommandButton": 'code
' etc
end select
next

(not tested)

Regards,
Peter T

"Nigel RS" wrote in message
...
Hi All
How can I identifiy the type of control (command button, testbox etc.) on

a
userform?

I wish to do two things...

1. Store the control type in a sheet cell
2. Use a conditional depending on the control type

Thanks




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
Identifying Control type Graham Payne Excel Programming 2 April 9th 06 09:15 AM
Identifying the type of a Worksheet_Change Peter Rooney Excel Programming 6 January 17th 06 02:38 PM
Userform Control Type VBA Dabbler[_2_] Excel Programming 4 June 10th 05 04:01 PM
Control Sequence from Userform Control Nigel Excel Programming 3 December 29th 04 01:25 PM
Identifying a Control Type Chrissy[_4_] Excel Programming 5 July 30th 03 08:25 AM


All times are GMT +1. The time now is 10: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"