我正在将一个范围复制到另一个工作簿的下一个空单元格中。以下代码;
Public Sub InvoicedInstallments()
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim fname As String
Dim mt As String, yr As String
mt = MonthBox.Value
yr = YearBox.Value
fname = yr & mt & "DB" & ".xlsx"
Set rng1 = Workbooks("201209TB.xlsx").Worksheets("excel").Range("E348")
Set rng2 = Workbooks("201209TB.xlsx").Worksheets("excel").Range("E295")
Set rng3 = Workbooks(fname).Worksheets("UK monthly dashboard").Cells(1, Columns.Count).End(xlToRight).Select
rng3.Value = (rng1.Value + rng2.Value)
rng3.Value = rng3.Value * -1
rng3.Value = Round(rng3.Value / 1000, 0)
End Sub
有过线
Set rng3 = Workbooks(fname).Worksheets("UK monthly dashboard").Cells(1, Columns.Count).End(xlToRight).Select
变成
Set rng3 = Workbooks(fname).Worksheets("UK monthly dashboard").Range("AA49").End(xlToRight).Offset(0, 1)
现在这会将数据放入下一个空单元格(这是我想要的),但如果您再次运行代码,它不会将信息放入下一个空单元格。
我想这只是一些简单的事情,但我无法发现它
它正在复制到合并的单元格中,我怀疑其中存在很多问题(请参阅下面的评论以确认这一点)