Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Copying labels to Userform at runtime.

I'm trying to set up an array of labels on a form at runtime.
The size of the array is determined from a textbox input at the top of the
form.
The sort of thing I want is like a blank crossword grid, where I can adjust
the caption in each label later to be 1 letter.
I've tried to copy a label and then paste it, but VBA doesn't allow this.
Has anyone any suggestions on how to achieve this?

TIA
Henry


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Copying labels to Userform at runtime.

Try something like the following. Change the various properties
to meet your needs.

Dim Ctrl As MSForms.Control
Set Ctrl = UserForm1.Controls.Add("Forms.Label.1", "Label1",
True)
Ctrl.Height = 10
Ctrl.Width = 10
Ctrl.Top = 10
Ctrl.Left = 10
Ctrl.Caption = "A"
UserForm1.Show


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Henry" wrote in message
...
I'm trying to set up an array of labels on a form at runtime.
The size of the array is determined from a textbox input at the
top of the form.
The sort of thing I want is like a blank crossword grid, where
I can adjust the caption in each label later to be 1 letter.
I've tried to copy a label and then paste it, but VBA doesn't
allow this.
Has anyone any suggestions on how to achieve this?

TIA
Henry



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Copying labels to Userform at runtime.

Thanks Chip,

The Label takes on the default colours of the form.
All I need now is to change the backcolor, forecolor and border for it to be
as I want.
(White, Black and a black border)
I cannot seem to change them from VBA like a normal Label.

Henry

"Chip Pearson" wrote in message
...
Try something like the following. Change the various properties to meet
your needs.

Dim Ctrl As MSForms.Control
Set Ctrl = UserForm1.Controls.Add("Forms.Label.1", "Label1", True)
Ctrl.Height = 10
Ctrl.Width = 10
Ctrl.Top = 10
Ctrl.Left = 10
Ctrl.Caption = "A"
UserForm1.Show


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Henry" wrote in message
...
I'm trying to set up an array of labels on a form at runtime.
The size of the array is determined from a textbox input at the top of
the form.
The sort of thing I want is like a blank crossword grid, where I can
adjust the caption in each label later to be 1 letter.
I've tried to copy a label and then paste it, but VBA doesn't allow this.
Has anyone any suggestions on how to achieve this?

TIA
Henry





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Copying labels to Userform at runtime.

Use the ForeColor and BackColor properties of the Ctrl object.

Ctrl.ForeColor = RGB(0, 0, 0)
Ctrl.BackColor = RGB(255, 255, 255)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Henry" wrote in message
...
Thanks Chip,

The Label takes on the default colours of the form.
All I need now is to change the backcolor, forecolor and border
for it to be as I want.
(White, Black and a black border)
I cannot seem to change them from VBA like a normal Label.

Henry

"Chip Pearson" wrote in message
...
Try something like the following. Change the various
properties to meet your needs.

Dim Ctrl As MSForms.Control
Set Ctrl = UserForm1.Controls.Add("Forms.Label.1", "Label1",
True)
Ctrl.Height = 10
Ctrl.Width = 10
Ctrl.Top = 10
Ctrl.Left = 10
Ctrl.Caption = "A"
UserForm1.Show


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Henry" wrote in message
...
I'm trying to set up an array of labels on a form at runtime.
The size of the array is determined from a textbox input at
the top of the form.
The sort of thing I want is like a blank crossword grid,
where I can adjust the caption in each label later to be 1
letter.
I've tried to copy a label and then paste it, but VBA doesn't
allow this.
Has anyone any suggestions on how to achieve this?

TIA
Henry







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Copying labels to Userform at runtime.

Thanks Chip,

Now working fine.

Henry


"Chip Pearson" wrote in message
...
Use the ForeColor and BackColor properties of the Ctrl object.

Ctrl.ForeColor = RGB(0, 0, 0)
Ctrl.BackColor = RGB(255, 255, 255)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Henry" wrote in message
...
Thanks Chip,

The Label takes on the default colours of the form.
All I need now is to change the backcolor, forecolor and border for it to
be as I want.
(White, Black and a black border)
I cannot seem to change them from VBA like a normal Label.

Henry

"Chip Pearson" wrote in message
...
Try something like the following. Change the various properties to meet
your needs.

Dim Ctrl As MSForms.Control
Set Ctrl = UserForm1.Controls.Add("Forms.Label.1", "Label1", True)
Ctrl.Height = 10
Ctrl.Width = 10
Ctrl.Top = 10
Ctrl.Left = 10
Ctrl.Caption = "A"
UserForm1.Show


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Henry" wrote in message
...
I'm trying to set up an array of labels on a form at runtime.
The size of the array is determined from a textbox input at the top of
the form.
The sort of thing I want is like a blank crossword grid, where I can
adjust the caption in each label later to be 1 letter.
I've tried to copy a label and then paste it, but VBA doesn't allow
this.
Has anyone any suggestions on how to achieve this?

TIA
Henry











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying labels to Userform at runtime.

I'm not sure I understand your problem... but you can try to fill in the
textbox_change() event with some code to do the rest...


"Henry" a écrit dans le message de news:
...
I'm trying to set up an array of labels on a form at runtime.
The size of the array is determined from a textbox input at the top of the
form.
The sort of thing I want is like a blank crossword grid, where I can
adjust the caption in each label later to be 1 letter.
I've tried to copy a label and then paste it, but VBA doesn't allow this.
Has anyone any suggestions on how to achieve this?

TIA
Henry



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
Using For/Next Loop To Generate 4 CommandButtons On A UserForm Results In A Runtime Error 91 Donna[_7_] Excel Programming 4 February 28th 05 01:21 PM
Vertical Alignment of text in Userform labels dht Excel Programming 1 June 16th 04 01:58 PM
Common format for Labels in Userform [email protected] Excel Programming 3 May 13th 04 11:14 AM
Add pictures to UserForm at runtime Dave[_33_] Excel Programming 1 December 6th 03 06:22 PM
add multiple checkboxes to userform at runtime gkelle Excel Programming 2 October 16th 03 04:16 PM


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