Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Apply vba code to multiple userform objects


Hello,

Allthough I've only recently started to program vba in excel, I suspec
there must be an easy way to apply vba code to multiple objects in
userform. Could anyone help me with this? I would like to 'group' th
lines in the example below:

ProjectenForm.EgKbA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgKmA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgKdA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHbA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHmA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHdA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKbA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKmA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKdA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHbA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHmA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHdA.BackStyle = fmBackStyleOpaque

Greetings,
Jori

--
sjoopi
-----------------------------------------------------------------------
sjoopie's Profile: http://www.excelforum.com/member.php...fo&userid=1611
View this thread: http://www.excelforum.com/showthread.php?threadid=27557

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Apply vba code to multiple userform objects

Use the controls collection. Something like this:

For every control on a form...
For Each C in Me.Controls

Next C

For specific controls with similar names

For nCounter = 1 to 10

Controls("txt" & nCounter).text = "test"

Next nCounter

for specific controls
vList = Array("txtA", "cbA","lstA")
For Each vCtl in Vlist
controls(vctl).enabled = true
Next vCtl

--
Robin Hammond
www.enhanceddatasystems.com
"sjoopie" wrote in message
...

Hello,

Allthough I've only recently started to program vba in excel, I suspect
there must be an easy way to apply vba code to multiple objects in a
userform. Could anyone help me with this? I would like to 'group' the
lines in the example below:

ProjectenForm.EgKbA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgKmA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgKdA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHbA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHmA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHdA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKbA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKmA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKdA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHbA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHmA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHdA.BackStyle = fmBackStyleOpaque

Greetings,
Joris


--
sjoopie
------------------------------------------------------------------------
sjoopie's Profile:
http://www.excelforum.com/member.php...o&userid=16110
View this thread: http://www.excelforum.com/showthread...hreadid=275576



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Apply vba code to multiple userform objects

Try this:

For Each ctl In ProjectenForm.Controls
ctl.BackStyle = fmBackStyleOpaque
Next

HTH,
Nikos

"sjoopie" wrote in message
...

Hello,

Allthough I've only recently started to program vba in excel, I suspect
there must be an easy way to apply vba code to multiple objects in a
userform. Could anyone help me with this? I would like to 'group' the
lines in the example below:

ProjectenForm.EgKbA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgKmA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgKdA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHbA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHmA.BackStyle = fmBackStyleOpaque
ProjectenForm.EgHdA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKbA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKmA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgKdA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHbA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHmA.BackStyle = fmBackStyleOpaque
ProjectenForm.MgHdA.BackStyle = fmBackStyleOpaque

Greetings,
Joris


--
sjoopie
------------------------------------------------------------------------
sjoopie's Profile:

http://www.excelforum.com/member.php...o&userid=16110
View this thread: http://www.excelforum.com/showthread...hreadid=275576



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
Make code apply to more than 1 column Cheryl Excel Discussion (Misc queries) 6 April 16th 10 10:02 PM
Prompt for a range to apply code to Steph[_3_] Excel Programming 2 April 29th 04 04:28 PM
Apply more than one filter in macro/vb code Stepnen Excel Programming 1 February 19th 04 07:49 PM
Would like to apply the code to protect cell sakijung Excel Programming 0 January 14th 04 09:13 AM
Can you Copy Objects from a Worksheet to a Userform Dave Baranas Excel Programming 0 August 14th 03 07:48 PM


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