Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA用户窗体标签间空间算法_Vba_Excel - Fatal编程技术网

VBA用户窗体标签间空间算法

VBA用户窗体标签间空间算法,vba,excel,Vba,Excel,我在userform代码中有一个算法,用于将月份名称动态添加到VBA用户表单中。我想添加3次月作为3个不同类别的标题。我的问题是,在我创建的算法中,前两个月之间的空间是1,第二个月和第三个月之间的空间是2倍。月份值在A4至A7单元格的工作表8中 在车库里看起来像这样 十二月-一月-二月 这是我的密码: 'months in commission, workdays and workhours Dim m As Integer 'm = month Dim T As Integer 'T=TOP

我在userform代码中有一个算法,用于将月份名称动态添加到VBA用户表单中。我想添加3次月作为3个不同类别的标题。我的问题是,在我创建的算法中,前两个月之间的空间是1,第二个月和第三个月之间的空间是2倍。月份值在A4至A7单元格的工作表8中

在车库里看起来像这样 十二月-一月-二月

这是我的密码:

'months in commission, workdays and workhours
Dim m As Integer 'm = month
Dim T As Integer 'T=TOP
Dim L As Integer 'L= loop

T = 50
For m = 1 To 3
    For L = 1 To 9
        DATA = ThisWorkbook.Worksheets(8).Range("A" & m + 3).Value
        Set dLbl = UserForm1.Controls.Add("Forms.Label.1", "dLbl", True)
        With dLbl
            .Top = 70
            If L < 4 Then
                .Left = 700 - (T * m)
            ElseIf L > 6 Then
                .Left = 190 - (T * m)
            Else
                .Left = 450 - (T * m)
            End If

            .Height = 50
            .Caption = DATA
            .Font.Bold = True
            .Font.Size = 11
            .Width = 45
            .TextAlign = fmTextAlignRight
        End With
    Next L
Next m
“佣金月份、工作日和工作时间
Dim m为整数'm=月份
尺寸T为整数'T=TOP
Dim L为整数'L=循环
T=50
对于m=1到3
对于L=1到9
数据=此工作簿。工作表(8)。范围(“A”&m+3)。值
Set dLbl=UserForm1.Controls.Add(“Forms.Label.1”,“dLbl”,True)
使用dLbl
.Top=70
如果L<4,则
.左=700-(T*m)
如果L>6那么
.左=190-(T*m)
其他的
.左=450-(T*m)
如果结束
.高度=50
.Caption=数据
.Font.Bold=True
.Font.Size=11
.宽度=45
.TextAlign=fmTextAlignRight
以
下一个L
下一个m

你能用这些标签添加屏幕截图吗?@PawelCzyz很遗憾我不能,我正在工作,这里的系统不允许我进行屏幕截图和上传。如果你能具体一点,也许我可以解释得更好。实际上,你的问题是什么还不清楚。你的代码怎么了?有错误吗?它做了什么而不是你所期望的?您还没有问任何问题。用户窗体有多宽?我发现如果它不是很宽的话,事情看起来很奇怪,但是当它足够宽的时候,分布看起来很正常。然而,我确实觉得奇怪的是,你把三个标签叠得很深——我只看到最后一次(3、6和9;我在标签名后面加上了L的值,并在测试中使用它作为标题)。