Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
don don is offline
external usenet poster
 
Posts: 21
Default Multiple TextBoxes_Populate

I Have a UserForm with many identical TextBoxes. I need to
populate them with varying types of format (ie backcolor,
forecolor, fontcolor etc) How can I do so, perhaps with
a "For Each" loop, rather than writing a separate code
block for each one.
I have tried things like:-
"For each TextBox in UserForm1"...... and
"For Count = 8 to 49 step 1
TextBox(Count).BackColor = something"
but either get "method not supported" or my syntax is
wrong.
Can anyone suggest code which will do this and if so,
where would it go - ie in a separate module, or in the
code for the TextBox and if the latter would the
Subroutine be a "Sub Initialise_???"
Any ideas would be greatly appreciated.
Don
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Multiple TextBoxes_Populate

Hi Don,

here is how you can access all the textboxes

Dim ctl As Control
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
ctl.BackColor = RGB(&H80, &H80, &H80)
End If
Next ctl

as to where to put it, that is more difficult. You need to determine which
event will change the textbox properties and then ad the code at that point.
There is no 'best' place.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Don" wrote in message
...
I Have a UserForm with many identical TextBoxes. I need to
populate them with varying types of format (ie backcolor,
forecolor, fontcolor etc) How can I do so, perhaps with
a "For Each" loop, rather than writing a separate code
block for each one.
I have tried things like:-
"For each TextBox in UserForm1"...... and
"For Count = 8 to 49 step 1
TextBox(Count).BackColor = something"
but either get "method not supported" or my syntax is
wrong.
Can anyone suggest code which will do this and if so,
where would it go - ie in a separate module, or in the
code for the TextBox and if the latter would the
Subroutine be a "Sub Initialise_???"
Any ideas would be greatly appreciated.
Don



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Multiple TextBoxes_Populate

If the colours are not likely to change again, UserForm_Initialize() is an
OK place to put it.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bob Phillips" wrote in message
...
Hi Don,

here is how you can access all the textboxes

Dim ctl As Control
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
ctl.BackColor = RGB(&H80, &H80, &H80)
End If
Next ctl

as to where to put it, that is more difficult. You need to determine which
event will change the textbox properties and then ad the code at that

point.
There is no 'best' place.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Don" wrote in message
...
I Have a UserForm with many identical TextBoxes. I need to
populate them with varying types of format (ie backcolor,
forecolor, fontcolor etc) How can I do so, perhaps with
a "For Each" loop, rather than writing a separate code
block for each one.
I have tried things like:-
"For each TextBox in UserForm1"...... and
"For Count = 8 to 49 step 1
TextBox(Count).BackColor = something"
but either get "method not supported" or my syntax is
wrong.
Can anyone suggest code which will do this and if so,
where would it go - ie in a separate module, or in the
code for the TextBox and if the latter would the
Subroutine be a "Sub Initialise_???"
Any ideas would be greatly appreciated.
Don





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
finding multiple code dates for multiple item number kmc Excel Worksheet Functions 3 February 6th 09 10:27 PM
Count multiple cells against multiple criteria in an Excel spreads EricB Excel Worksheet Functions 7 June 3rd 08 09:09 PM
Automated multiple text files into multiple sheets in one workbook Dr Dan Excel Discussion (Misc queries) 14 November 4th 07 11:32 AM
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
view multiple files in multiple windows on multiple screens. tcom Excel Discussion (Misc queries) 7 September 15th 05 09:35 PM


All times are GMT +1. The time now is 10:46 AM.

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"