我有一张表格(让我们称之为sheet1),在开放时会更新。所以我要在sheet1
中说:
a1 one
a2 two
a3 three
Sheet1
已配置为在打开时更新数据。
我希望这些数据在下一个可用的空行中填充到Sheet2
。因此,如果我已经在a1-a3
中有数据,我希望将这些新数据复制到b1-b3
,依此类推。
有关如何实现这一目标的任何想法? 谢谢! 肯
答案 0 :(得分:1)
您应该提交问题代码,而不是要求提供问题代码,但这非常简单。如果需要调整以满足您的需求,请尝试调整它。如果你遇到困难,那就问一个关于如何做的新的,更具体的问题,或者为什么会出错。
无论如何,你需要一些VBA:
Sub someVBA()
'Set the sheets we are working with - change as needed
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Worksheets("Sheet1")
Set s2 = Worksheets("Sheet2")
'Find the last column in s2 by going way out to the end of
' of the sheet and using end(xlToLeft) and adding 1 more column
' to that. That's the next blank column
Dim lastCol As Integer
lastCol = s2.Cells(1, 1000).End(xlToLeft).Column() + 1
'Copy it over
s2.Columns(lastCol).Value = s1.Columns(1).Value
End Sub