Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I use an array such as mylabel(5) I cannot actually use the array
latter on in another function because the labels are not actually named mylabel(1), mylabel(2), etc. So I guess I have to store each of the label names in a sheet and get them back later. The following code will do essentially what I want. Is there a better way? Private Sub CommandButton1_Click() Dim counter As Integer counter = 1 Dim mylabel(5) As Label Do Until counter = 6 '//ActiveSheet.Labels.Add(.Left, .Top, .Width, .Height) Set mylabel(counter) = ActiveSheet.Labels.Add(20, 300 + 20 * counter, 100, 20) mylabel(counter).Visible = True 'mylabel(counter).Caption = "This is mylabel(" & counter & ")" mylabel(counter).Caption = "This is mylabel(" & counter & ")" & _ "Its name is" & mylabel(counter).Name '//store label names in sheet Range(Cells(19 + counter, 1).Address).Value = mylabel(counter).Name counter = counter + 1 Loop End Sub Private Sub CommandButton2_Click() Dim mylabel_names(5) As String Dim counter As Integer counter = 1 Do Until counter = 6 mylabel_names(counter) = Range(Cells(19 + counter, 1).Address).Value On Error Resume Next ActiveSheet.Labels(mylabel_names(counter)).delete counter = counter + 1 Loop End Sub Private Sub CommandButton3_Click() ActiveSheet.Labels.delete End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Programmatically create button on Excel worksheet (vb.net) | Excel Programming | |||
How do I use a worksheet label to create a formula in Excel 2007? | Excel Discussion (Misc queries) | |||
How do I use a worksheet label to create a formula in Excel 2007? | Excel Discussion (Misc queries) | |||
label x-axis values programmatically | Charts and Charting in Excel | |||
Create UserForm programmatically | Excel Programming |