Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.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,Excel+VBA 我有一个文件,有4列ID,没有线轴,包装/交付长度。 我正在做的是将基于无假脱机的行数写入另一个工作表(您可以在“CreateOrders”工作表中查看数据,以便更好地理解)。 这是正常工作,但我有一个问题。我之前在“到期日”表中提到:“CreateOrders”放的是“今天的日期”,但现在想根据上一张表“PROGRAMA COBRE”中的ID放一个特定的日期,例如: 发件人: 致: 我的文件:http://speedy.sh/s4peR/Livro3.xlsm 我是手工

Excel+VBA

我有一个文件,有4列ID,没有线轴,包装/交付长度。 我正在做的是将基于无假脱机的行数写入另一个工作表(您可以在“CreateOrders”工作表中查看数据,以便更好地理解)。 这是正常工作,但我有一个问题。我之前在“到期日”表中提到:“CreateOrders”放的是“今天的日期”,但现在想根据上一张表“PROGRAMA COBRE”中的ID放一个特定的日期,例如:

发件人:

致:

我的文件:
http://speedy.sh/s4peR/Livro3.xlsm

我是手工做的,把所有的日期都“手工”放进去,但是我怎么能自动做到呢

谢谢你的帮助

编辑(我的代码):


这就是你正在尝试的(未经测试的)吗?将循环的
更改为此

For Each c In Range("B2:B" & Cells(Rows.Count, 1).End(xlUp).Row)
    a = c.Value

    With sh2.Cells(Rows.Count, 3).End(xlUp).Offset(1).Resize(a, 3)
        .Value = Array(c.Offset(, -1).Value, 1, c.Offset(, 1).Value)
    End With

    '~~> The below "should" fill the Column B with Dates.
    With sh2.Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(a, 1)
        .Value = c.Offset(, 2).Value
    End With
Next c

这就是你正在尝试的(未经测试的)吗?将循环的
更改为此

For Each c In Range("B2:B" & Cells(Rows.Count, 1).End(xlUp).Row)
    a = c.Value

    With sh2.Cells(Rows.Count, 3).End(xlUp).Offset(1).Resize(a, 3)
        .Value = Array(c.Offset(, -1).Value, 1, c.Offset(, 1).Value)
    End With

    '~~> The below "should" fill the Column B with Dates.
    With sh2.Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(a, 1)
        .Value = c.Offset(, 2).Value
    End With
Next c

如果您在问题中包含有问题的代码或尝试,而不是仅仅发布一个指向工作簿副本的链接,您可能会得到更好的响应如果您在问题中包含有问题的代码或尝试,而不是仅仅发布指向工作簿副本的链接,您可能会得到更好的响应