Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA code to list names of controls on user form?

Hi guys,

Can anyone suggest how I could write some code that would return all
the control names on a user form?

I've designed the form and re-named all the controls to something
meaningful. I know that when I right click the form to get a tab order
it displays all the field names so what I really want is a similar
thing that I can output for reference when writing the code.

Thanks in advance

Pete

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA code to list names of controls on user form?

OK - I guess someone is going to tell me to search the archives before
posting - and you'd be right!

Sorry to take up your time, I did it by using

Sub getNames()

Dim ctl As Control
Dim i As Integer

i = 2

For Each ctl In frmBook.Controls
Sheet3.Activate
Cells(i, 1) = ctl.Name
i = i + 1
Next ctl


End Sub

based on a posting from 2003.

Apologies for not being diligent!

Pete




Peter wrote:

Hi guys,

Can anyone suggest how I could write some code that would return all
the control names on a user form?

I've designed the form and re-named all the controls to something
meaningful. I know that when I right click the form to get a tab order
it displays all the field names so what I really want is a similar
thing that I can output for reference when writing the code.

Thanks in advance

Pete


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default VBA code to list names of controls on user form?

Hi Pete,

Try something like:

'=============
Public Sub Tester()
Dim CTRL
Dim i As Long

For Each CTRL In UserForm1.Controls
i = i + 1
Cells(i, 1).Value = CTRL.Name
Next CTRL

End Sub
'<<=============


---
Regards,
Norman


"Peter" wrote in message
oups.com...
Hi guys,

Can anyone suggest how I could write some code that would return all
the control names on a user form?

I've designed the form and re-named all the controls to something
meaningful. I know that when I right click the form to get a tab order
it displays all the field names so what I really want is a similar
thing that I can output for reference when writing the code.

Thanks in advance

Pete



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA code to list names of controls on user form?

Thanks Norman - I appreciate the reply. That definitely works!


Norman Jones wrote:
Hi Pete,

Try something like:

'=============
Public Sub Tester()
Dim CTRL
Dim i As Long

For Each CTRL In UserForm1.Controls
i = i + 1
Cells(i, 1).Value = CTRL.Name
Next CTRL

End Sub
'<<=============


---
Regards,
Norman


"Peter" wrote in message
oups.com...
Hi guys,

Can anyone suggest how I could write some code that would return all
the control names on a user form?

I've designed the form and re-named all the controls to something
meaningful. I know that when I right click the form to get a tab order
it displays all the field names so what I really want is a similar
thing that I can output for reference when writing the code.

Thanks in advance

Pete


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
User form controls add nath Excel Programming 1 May 26th 04 10:58 AM
User Form Controls Keith Willshaw Excel Programming 0 August 29th 03 01:20 PM
User Form Controls Tom Ogilvy Excel Programming 0 August 29th 03 12:42 PM
User Form Controls Zaid Qureshi Excel Programming 0 August 29th 03 12:40 PM
user form controls chris gee Excel Programming 0 July 15th 03 12:05 AM


All times are GMT +1. The time now is 01:53 AM.

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"