Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Identifying Control type | Excel Programming | |||
Identifying the type of a Worksheet_Change | Excel Programming | |||
Userform Control Type | Excel Programming | |||
Control Sequence from Userform Control | Excel Programming | |||
Identifying a Control Type | Excel Programming |