LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Dynamically Adding Labels to a Userform

I'm trying to add a series of labels to a userform at runtime. I'm
stuck on a couple of aspects.

1. It looks like each label needs a unique name (true??). I'm not able
to do this.
2. When I set up each label, I need to assign it various properties.
Some of these are easy (e.g. height, width, etc.). But others don't
seem to be legal options (e.g. TextAlign)

Here is my non-working code:

'Generate Table of each problem attempted
Dim i As Integer
Dim newLbl As MSForms.Control
Dim lblName, strProb, strResult As String

For i = 1 To 1 'numAttempts

'Label for Question Number
lblName = "Forms.Label.Q" '& Right(i * 1000, 3) & ".1"
Set newLbl =
Me.Controls.Add(lblName) 'Run-time
error - Invalid Class String
newLbl.Caption = Range("results").Offset(i - 1, 0).Value

With newLbl
.Left = 54
.Top = 198
.Visible = True
.Height = 12
.Width = 24
.TextAlign = 'Not legal here??? How do I do this?
End With

Next i

Can anyone help? Thanks!
 
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
add data labels in charts with tools (dynamically) uriel78 Charts and Charting in Excel 2 April 15th 05 01:11 AM
dynamically create userform Janelle Excel Programming 7 December 17th 04 04:47 PM
How to create labels in a UserForm dynamically and be able to resize them with the mouse. Pierre Archambault Excel Programming 0 November 23rd 04 08:39 PM
Referencing labels dynamically. liddlem[_3_] Excel Programming 2 January 16th 04 05:24 PM
Dynamically Adding Code to Buttons on an existing UserForm Peter Street Excel Programming 2 September 29th 03 09:54 AM


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