LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Apply vba code to multiple userform objects

Or test the control type

For Each ctl In ProjectenForm.Controls
If Typename(ctl) = "TextBox" Then
ctl.BackStyle = fmBackStyleOpaque
End If
Next


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nikos Yannacopoulos" wrote in message
...
That's because you are trying to set the backstyle property of a control
that doesn't have one, such as a command button, for instance. You need to
make some provision in your code to set the property of the desired

controls
only. Looking at the names of the controls in your first post, it looks

like
the following could work:

For Each ctl In ProjectenForm.Controls
If Left(ctl.Name, 2) = "Eg" Or Left(ctl.Name, 2) = "Mg" Then
ctl.BackStyle = fmBackStyleOpaque
End If
Next

provided that the name of the control causing the error doesn't start with
Eg or Mg.

HTH,
Nikos

"sjoopie" wrote in message
...

Thanks for the help,

on the following line:

ctl.BackStyle = fmBackStyleOpaque

i receive error message 438


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

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

http://www.excelforum.com/showthread...hreadid=275576





 
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
Apply vba code to multiple userform objects sjoopie Excel Programming 2 November 5th 04 12:15 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 07:14 PM.

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"